| From: | vignesh C <vignesh21(at)gmail(dot)com> |
|---|---|
| To: | Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> |
| Cc: | shveta malik <shveta(dot)malik(at)gmail(dot)com>, "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>, Noah Misch <noah(at)leadboat(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: sequencesync worker race with REFRESH SEQUENCES |
| Date: | 2026-07-23 04:14:34 |
| Message-ID: | CALDaNm2WzVvjibSGfKKDoPjt6B0G+AjzGVReGoLfdJQtG=qG=g@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Wed, 22 Jul 2026 at 16:16, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
>
> On Wed, Jul 22, 2026 at 8:16 AM vignesh C <vignesh21(at)gmail(dot)com> wrote:
> >
> > The attached patch has the changes for the same. This patch also fixes
> > the issue reported by Kuroda-san at [1].
> >
>
> The patch used two different error codes
> (ERRCODE_FEATURE_NOT_SUPPORTED and
> ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE) for the same condition. I
> preferred to use ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE in both
> places because the error is about the remote server's state (it isn't
> new enough), not about a capability this backend fails to implement.
> That's exactly what OBJECT_NOT_IN_PREREQUISITE_STATE is for, and it's
> what the existing publisher-version guards use. OTOH,
> FEATURE_NOT_SUPPORTED reads as "PostgreSQL doesn't implement this" —
> misleading here, since sequence sync is implemented; the publisher
> just predates it.
>
> I made this change and slightly changed the comments in the patch. See attached.
Thanks for the updated patch.
I verified the following scenarios:
Scenario 1:
1. Create a logical replication setup with sequence publication on
PostgreSQL 20.
2. Change the subscription connection to point to a PostgreSQL 18 publisher.
3. Run 'ALTER SUBSCRIPTION ... REFRESH SEQUENCES'.
The command fails with expected error:
ERROR: cannot synchronize sequences if the publisher is running a
version earlier than PostgreSQL 19
Scenario 2:
1. Create a logical replication setup with sequence publication on
PostgreSQL 20, but create the subscription with 'WITH (enabled =
false)' so that the sequences remain in the INIT state in
'pg_subscription_rel'.
2. Change the subscription connection to point to a PostgreSQL 18 publisher.
3. Enable the subscription, which starts the sequence synchronization worker.
It logs the expected error logs:
ERROR: cannot synchronize sequences if the publisher is running a
version earlier than PostgreSQL 19
I also verified the above scenarios with PostgreSQL 19 logical
replication setup and changing the connection to PostgreSQL 18
publication
I tested both scenarios using the 'CONNECTION' and 'SERVER' variants
of 'SUBSCRIPTION', and in both cases it works as expected.
The changes look good to me.
Regards,
Vignesh
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Jacob Brazeal | 2026-07-23 04:31:11 | [PATCH] Fix temporal foreign key validation of pre-existing rows |
| Previous Message | Hayato Kuroda (Fujitsu) | 2026-07-23 03:00:18 | RE: [Bug] pg_upgrade could fail for non-superuser subscriptions using foreign servers |