Re: Logical Replication of sequences
Nisha Moond <nisha.moond412@gmail.com>
From: Nisha Moond <nisha.moond412@gmail.com>
To: vignesh C <vignesh21@gmail.com>
Cc: shveta malik <shveta.malik@gmail.com>,
Amit Kapila <amit.kapila16@gmail.com>, Peter Smith <smithpb2250@gmail.com>, "Hayato Kuroda (Fujitsu)" <kuroda.hayato@fujitsu.com>,
Masahiko Sawada <sawada.mshk@gmail.com>, Shlok Kyal <shlok.kyal.oss@gmail.com>,
Peter Eisentraut <peter@eisentraut.org>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>,
Euler Taveira <euler@eulerto.com>, Michael Paquier <michael@paquier.xyz>,
"Zhijie Hou (Fujitsu)" <houzj.fnst@fujitsu.com>, "Jonathan S. Katz" <jkatz@postgresql.org>
Date: 2025-07-10T11:47:17Z
Lists: pgsql-hackers
On Wed, Jul 9, 2025 at 4:11 PM vignesh C <vignesh21@gmail.com> wrote:
>
> The attached v20250709 version patch has the changes for the same.
>
Thanks for the patches.
In Patch-004: sequencesync.c : I think below function logic can be simplified.
+void
+ProcessSyncingSequencesForApply(void)
+{
+ bool started_tx = false;
+
+ Assert(!IsTransactionState());
+
+ /* Start the sequencesync worker if needed, and there is not one already. */
+ foreach_ptr(SubscriptionRelState, rstate, sequence_states_not_ready)
+ {
...
Currently, we loop through all INIT sequences to start a sequencesync
worker. But since a single worker handles synchronization for all the
sequences in list "sequence_states_not_ready", iterating through the
entire list may lead to unnecessary work in cases like:
a) when no sync worker slots are available (e.g., nsyncworkers ==
max_sync_workers_per_subscription), or
b) when sequencesync_failure_time hasn't yet elapsed.
We could instead check if the list is non-empty (or use a simple bool)
and attempt to start the worker. If it can’t be started, we can try
again in the next apply loop.
Thoughts?
--
Thanks.
Nisha