| From: | Fujii Masao <masao(dot)fujii(at)gmail(dot)com> |
|---|---|
| To: | Shlok Kyal <shlok(dot)kyal(dot)oss(at)gmail(dot)com> |
| Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: Two issues with version checks in CREATE SUBSCRIPTION |
| Date: | 2025-12-24 14:48:25 |
| Message-ID: | CAHGQGwGsqBT+MHGf23Sdfkw2+1GiCOah6vQ7cWOSjRUDoLki2Q@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Tue, Dec 23, 2025 at 7:18 PM Shlok Kyal <shlok(dot)kyal(dot)oss(at)gmail(dot)com> wrote:
>
> Hi Fujii-san,
>
> On Mon, 22 Dec 2025 at 22:57, Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
> >
> > Hi,
> >
> > While looking at subscription-related code, I noticed two issues related to
> > version checks.
> >
> > if (walrcv_server_version(wrconn) < 19000)
> > ereport(ERROR,
> > errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
> > errmsg("cannot enable retain_dead_tuples if the
> > publisher is running a version earlier than PostgreSQL 19"));
> >
> > First, in subscriptioncmds.c this check rejects enabling retain_dead_tuples
> > when the publisher is running an older version. However, the comparison uses
> > 19000 as v19 value. Since server versions are encoded as 190000 for v19,
> > this appears to be a typo and allows the option to be enabled unexpectedly
> > on pre-v19 publishers. The attached 0001 patch fixes this by correcting
> > the version constant.
> >
> I tested this. I created a publisher in PG17 and tried creating
> subscriber in PG19.
>
> Without Patch, I am able to create the subscription with
> retain_dead_tuples = true.
> postgres=# CREATE SUBSCRIPTION sub1 CONNECTION 'host=localhost
> port=5432 dbname=postgres' PUBLICATION pub1 WITH (retain
> _dead_tuples=true);
> NOTICE: created replication slot "sub1" on publisher
> CREATE SUBSCRIPTION
>
> With 0001 Patch, this issue is resolved.
> postgres=# CREATE SUBSCRIPTION sub2 CONNECTION 'host=localhost
> port=5432 dbname=postgres' PUBLICATION pub1 WITH
> (retain_dead_tuples=true);
> ERROR: cannot enable retain_dead_tuples if the publisher is running a
> version earlier than PostgreSQL 19
>
> > Second, CREATE SUBSCRIPTION with copy_data=true and origin='none' currently
> > fails when the publisher is running a version earlier than v19, although
> > this combination should be supported. The failure occurs because the command
> > issues a query calling pg_get_publication_sequences on the publisher,
> > which does not exist before v19. The attached 0002 patch fixes this
> > by skipping that query when the publisher runs an older version.
> >
> I am able to reproduce this scenario.
> I created a publisher in PG17 and tried creating subscriber in PG19.
>
> Without Patch we are hitting the following error.
> postgres=# CREATE SUBSCRIPTION sub1 CONNECTION 'host=localhost
> port=5432 dbname=postgres' PUBLICATION pub1 WITH (origin='none');
> ERROR: could not receive list of replicated sequences from the
> publisher: ERROR: function pg_get_publication_sequences(name) does
> not exist
> LINE 3: LATERAL pg_get_publication_sequences(P.pubname) GPS
> ^
> HINT: No function matches the given name and argument types. You
> might need to add explicit type casts.
>
> And I confirm that the 0002 patch resolves this.
Thanks for the review and test! I've pushed the patches.
Regards,
--
Fujii Masao
| From | Date | Subject | |
|---|---|---|---|
| Next Message | KAZAR Ayoub | 2025-12-24 15:07:55 | Re: Speed up COPY FROM text/CSV parsing using SIMD |
| Previous Message | Jelte Fennema-Nio | 2025-12-24 14:31:47 | Re: cleanup: Split long Makefile lists across lines and sort them |