Re: Logical Replication of sequences - Mailing list pgsql-hackers

From Nisha Moond
Subject Re: Logical Replication of sequences
Date
Msg-id CABdArM640YF7MQfMVhEX=e1pJdrnVcCwS_y4XXsbvah=6P9S=A@mail.gmail.com
Whole thread Raw
In response to Re: Logical Replication of sequences  (vignesh C <vignesh21@gmail.com>)
List 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



pgsql-hackers by date:

Previous
From: Ashutosh Bapat
Date:
Subject: Re: Using failover slots for PG-non_PG logical replication
Next
From: Dilip Kumar
Date:
Subject: Re: A recent message added to pg_upgade