On Wed, Feb 25, 2026 at 8:32 AM Amit Kapila <[email protected]> wrote:
>
> On Tue, Feb 24, 2026 at 6:49 PM Dilip Kumar <[email protected]> wrote:
> >
> > On Tue, Feb 24, 2026 at 4:55 PM Amit Kapila <[email protected]> wrote:
> > >
> > > On Tue, Feb 24, 2026 at 4:34 PM Ajin Cherian <[email protected]> wrote:
> > > >
> > > > Currently REFRESH SEQUENCES can only be called if the subscription is
> > > > enabled. All it does is change the states of all the sequences in
> > > > subscription_rel to INIT, this will prompt the sequence worker to wake
> > > > up and unconditionally sync all the sequences. For sequences in the
> > > > INIT state, it doesn't check if there is drift or not, it updates all
> > > > sequences unconditionally. From your discussions with Dilip, I
> > > > understand we want to reduce the time it takes to REFRESH SEQUENCES at
> > > > the time of an upgrade. If so, then this might not be a good approach.
> > > >
> > >
> > > The point I was trying to make is that with automatic sequence sync,
> > > we won't need to execute REFRESH SEQUENCES before upgrade or failover
> > > as the sequences will be in sync.
> > >
> >
> > That is a valid goal, however, the sequence sync worker is an
> > asynchronous process triggered at specific intervals. For a switchover
> > to guarantee consistency, we must disconnect all connections from the
> > current publisher and wait for all pending data to sync. Relying on an
> > automated, interval-based worker at this critical time is risky, as it
> > directly extends our downtime. To minimize the cutover window, we
> > should either treat sequence data the same as relational data
> > (synchronous streaming) or manually trigger for the sequence sync
> > during the switchover phase, i.e. REFRESH SEQUENCES.  Anyway this is
> > my understanding, do you have anything else in mind that how you are
> > trying to completely avoid REFRESH SEQUENCES.  Having said that I
> > agree that in many cases where sequences are not frequently modified
> > it is very much possible that when we are in switchover phase all
> > sequences are already in sync and if we can identify that then we can
> > avoid REFRESH SEQUENCES, but my point is we can not completely avoid
> > that in all caes.
> >
>
> Right, I am also of the point that we can't completely avoid REFRESH
> SEQUENCES in all cases. Having sequence sync worker syncing
> periodically reduces the chances that one need to perform REFRESH
> SEQUENCES, so we need both. Do we agree with that?
>
> Additionally, I am thinking that after sync-worker we change REFRESH
> SEQUENCES functionality such that it will refresh all sequences during
> command. And, even we fail to copy one sequence, the command should
> fail. This should use almost the same functionality (like we sync only
> the required ones) as syncworker but online. This is because the case
> where it would be used will be less likely, say when due to some
> reason like max_logical_workers limit, we are not able to invoke
> sequencesync worker or just before upgrade (when sequences are not
> already synced), so doing sync during refresh command sounds
> reasonable. What do you think?
>

I agree with the overall direction of the discussion. But this is how
I look at it:

Given that sequences can be large, it’s not always practical and may
place an unnecessary burden on users to manually verify whether all
sequences are in sync before an upgrade. Requiring users to inspect
sequence values and manually determine drift before deciding whether
to run REFRESH introduces unnecessary operational complexity. So
instead of trying to find ways to avoid REFRESH, we can position it as
the final safety step before upgrade, optimized to refresh only
drifted sequences and to fail if synchronization of any required
sequence does not succeed. This approach gives us several advantages:

--Users don’t need to manually check for drift.
--REFRESH becomes a safe, final synchronization step before upgrade.
--In most real-world scenarios, sequences are likely already in sync
due to the periodic sync worker. When everything is already
synchronized, REFRESH effectively becomes a lightweight confirmation
check.
--If some sequences are out of sync (due to high activity, worker
limits such as max_logical_replication_workers, or other edge cases),
REFRESH will correct only those.

This creates a practical win-win situation: fast execution when
sequences are already in sync, guaranteed correctness when they are
not, and no additional manual validation burden on the user. Thoughts?

thanks
Shveta


Reply via email to