| From: | Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> |
|---|---|
| To: | shveta malik <shveta(dot)malik(at)gmail(dot)com> |
| Cc: | vignesh C <vignesh21(at)gmail(dot)com>, Noah Misch <noah(at)leadboat(dot)com>, pgsql-hackers(at)postgresql(dot)org |
| Subject: | Re: sequencesync worker race with REFRESH SEQUENCES |
| Date: | 2026-07-14 02:51:32 |
| Message-ID: | CAA4eK1+6JnnCs_2=Odtz0PK7_Kq+CxZeo+ob8ND42-NQiZ9zEw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Mon, Jul 13, 2026 at 5:46 PM shveta malik <shveta(dot)malik(at)gmail(dot)com> wrote:
>
> 2)
> The fix will solve the purpose. But I have a doubt for the check in
> copy_sequences(). Say a few sequences are already in the INIT state,
> and the subscription is then repointed to a pre-PG19 publisher. Would
> the apply worker keep launching the sequence sync worker, only for it
> to exit each time with this error of copy_sequences? Is my
> understanding correct? If so, is there a way to avoid launching the
> sequence sync worker altogether when connected to a pre-PG19
> publisher? We do have 'LogRepWorkerWalRcvConn' in the apply worker to
> check the version.
>
Good question. I think to handle the case you pointed and even REFRESH
SEQUENCES case, isn't it better to raise an ERROR when the user is
trying to point connection to a version prior to 19 and the subscriber
has sequences? For example, we do something similar retain_dead_tuples
parameter in AlterSubscription, see handling of
ALTER_SUBSCRIPTION_SERVER/ALTER_SUBSCRIPTION_CONNECTION->check_pub_rdt
in AlterSubscription().
One additional comment on 0001:
===========================
*
@@ -435,6 +435,19 @@ copy_sequences(WalReceiverConn *conn)
StringInfoData cmd;
MemoryContext oldctx;
+ /*
+ * Sequence synchronization relies on pg_get_sequence_data(), which is
+ * only available since PostgreSQL 19. Fail with a clear diagnosis
+ * instead of sending a query that the publisher cannot execute (or
+ * cannot even parse), which would otherwise make this worker exit with
+ * a confusing "invalid query response" error.
+ */
+ if (walrcv_server_version(conn) < 190000)
+ ereport(ERROR,
+ errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot synchronize sequences for subscription \"%s\" because
the publisher is running a version earlier than PostgreSQL 19",
+ MySubscription->name));
I think it is better to move this check to the caller immediately
after making a connection to the publisher. Also, the second part of
the comment: "Fail with a clear diagnosis instead of sending a query
that the ..." appears redundant to me as the code is explicit about
the case.
--
With Regards,
Amit Kapila.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Amit Kapila | 2026-07-14 03:24:46 | Re: sequencesync worker race with REFRESH SEQUENCES |
| Previous Message | Michael Paquier | 2026-07-14 01:37:05 | Re: [Proposal] Adding callback support for custom statistics kinds |