Re: Logical Replication of sequences
vignesh C <vignesh21@gmail.com>
Commits
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Doc: Add documentation for sequence synchronization.
- 55cefadde874 19 (unreleased) landed
-
Remove unused assignment in CREATE PUBLICATION grammar.
- bfb7419b0bbe 19 (unreleased) landed
-
Add seq_sync_error_count to subscription statistics.
- f6a4c498dcf6 19 (unreleased) landed
-
Fix few issues in commit 5509055d69.
- 5a4eba558aa7 19 (unreleased) landed
-
Add sequence synchronization for logical replication.
- 5509055d6956 19 (unreleased) landed
-
Add worker type argument to logical replication worker functions.
- 3e8e05596a02 19 (unreleased) landed
-
Introduce "REFRESH SEQUENCES" for subscriptions.
- f0b3573c3aac 19 (unreleased) landed
-
Refactor logical worker synchronization code into a separate file.
- 41c674d2e31e 19 (unreleased) landed
-
Standardize use of REFRESH PUBLICATION in code and messages.
- 2436b8c047ff 19 (unreleased) landed
-
Add "ALL SEQUENCES" support to publications.
- 96b378497346 19 (unreleased) landed
-
Expose sequence page LSN via pg_get_sequence_data.
- b93172ca59f4 19 (unreleased) landed
-
Resume conflict-relevant data retention automatically.
- 0d48d393d465 19 (unreleased) cited
-
Post-commit review fixes for 228c370868.
- 1f7e9ba3ac4e 19 (unreleased) cited
-
Generate GUC tables from .dat file
- 63599896545c 19 (unreleased) cited
Attachments
- v20250716-0001-Introduce-pg_sequence_state-function-for-e.patch (application/octet-stream) patch v20250716-0001
- v20250716-0004-Introduce-REFRESH-PUBLICATION-SEQUENCES-fo.patch (application/octet-stream) patch v20250716-0004
- v20250716-0003-Reorganize-tablesync-Code-and-Introduce-sy.patch (application/octet-stream) patch v20250716-0003
- v20250716-0002-Introduce-ALL-SEQUENCES-support-for-Postgr.patch (application/octet-stream) patch v20250716-0002
- v20250716-0005-New-worker-for-sequence-synchronization-du.patch (application/octet-stream) patch v20250716-0005
- v20250716-0006-Documentation-for-sequence-synchronization.patch (application/octet-stream) patch v20250716-0006
On Tue, 15 Jul 2025 at 11:27, shveta malik <shveta.malik@gmail.com> wrote: > > Thank You. Few comments: > > 1) > patch 005 has trailing whitespaces issue. Fixed them > 2) > In LogicalRepSyncSequences(), do we really need this: > > + seq_count = list_length(subsequences);; > > seq_count is only used at the end to figure out if we really had some > sequences. We can simply check subsequences against NIL for that > purpose. If we really want to use list_length as a check, then we > shall move it at the end where we use it. Modified > 3) > LogicalRepSyncSequences(): > + MemoryContext oldctx; > > we can move this to a for-loop where it is being used. Modified > 4) > The only usage of sequence_states_not_ready is this now: > > + /* No sequences to sync, so nothing to do */ > + if (list_length(sequence_states_not_ready) == 0) > + return; > > Now, do we need to have it as a List? Removed this list variable and used a output function argument in FetchRelationStates > 5) > + <sect2 id="missing-sequences"> > + <title>Missing Sequences</title> > + <para> > + During sequence synchronization, if a sequence is dropped on the > + publisher. An ERROR is logged listing the missing sequences before the > + process exits. The apply worker detects this failure and repeatedly > + respawns the sequence synchronization worker to continue the > + synchronization process until the sequences are created in the publisher. > + See also <link > linkend="guc-wal-retrieve-retry-interval"><varname>wal_retrieve_retry_interval</varname></link>. > + </para> > + <para> > + To resolve this, either use > + <link linkend="sql-createsequence"><command>CREATE > SEQUENCE</command></link> > + to recreate the missing sequence on the publisher, or, if the sequence are > + no longer required, execute <link > linkend="sql-altersubscription-params-refresh-publication"> > + <command>ALTER SUBSCRIPTION ... REFRESH PUBLICATION</command></link> > + to remove the stale sequence entries from synchronization in the > subscriber. > + </para> > + </sect2> > + > > Please see if this looks appropriate, I have added drop-sequence > option as well and corrected few trivial things: > > During sequence synchronization, if a sequence is dropped on the > publisher, an ERROR is logged listing the missing sequences before the > process exits. The apply worker detects this failure and repeatedly > respawns the sequence synchronization worker to continue the > synchronization process until the sequences are either recreated on > the publisher, dropped on the subscriber, or removed from the > synchronization list. > > To resolve this issue, either recreate the missing sequence on the > publisher using CREATE SEQUENCE, drop the sequences on the subscriber > if they are no longer needed using DROP SEQUENCE, or run ALTER > SUBSCRIPTION ... REFRESH PUBLICATION to remove these sequences from > synchronization on the subscriber. Modified The attached v20250716 version patch has the changes for the same. Regards, Vignesh