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
- v20240620-0002-Introduce-ALL-SEQUENCES-support-for-Postgr.patch (text/x-patch) patch v20240620-0002
- v20240620-0001-Introduce-pg_sequence_state-and-SetSequenc.patch (text/x-patch) patch v20240620-0001
- v20240620-0003-Enhance-sequence-synchronization-during-su.patch (text/x-patch) patch v20240620-0003
On Wed, 19 Jun 2024 at 20:33, vignesh C <vignesh21@gmail.com> wrote: > > On Tue, 18 Jun 2024 at 16:10, Amit Kapila <amit.kapila16@gmail.com> wrote: > > > > > > Agreed and I am not sure which is better because there is a value in > > keeping the state name the same for both sequences and tables. We > > probably need more comments in code and doc updates to make the > > behavior clear. We can start with the sequence state as 'init' for > > 'needs-to-be-sycned' and 'ready' for 'synced' and can change if others > > feel so during the review. > > Here is a patch which does the sequence synchronization in the > following lines from the above discussion: > This commit introduces sequence synchronization during 1) creation of > subscription for initial sync of sequences 2) refresh publication to > synchronize the sequences for the newly created sequences 3) refresh > publication sequences for synchronizing all the sequences. > 1) During subscription creation with CREATE SUBSCRIPTION (no syntax change): > - The subscriber retrieves sequences associated with publications. > - Sequences are added in the 'init' state to the pg_subscription_rel table. > - Sequence synchronization worker will be started if there are any > sequences to be synchronized > - A new sequence synchronization worker handles synchronization in > batches of 100 sequences: > a) Retrieves sequence values using pg_sequence_state from the publisher. > b) Sets sequence values accordingly. > c) Updates sequence state to 'READY' in pg_susbcripion_rel > d) Commits batches of 100 synchronized sequences. > 2) Refreshing sequences with ALTER SUBSCRIPTION ... REFRESH > PUBLICATION (no syntax change): > - Stale sequences are removed from pg_subscription_rel. > - Newly added sequences in the publisher are added in 'init' state > to pg_subscription_rel. > - Sequence synchronization will be done by sequence sync worker as > listed in subscription creation process. > - Sequence synchronization occurs for newly added sequences only. > 3) Introduce new command ALTER SUBSCRIPTION ... REFRESH PUBLICATION > SEQUENCES for refreshing all sequences: > - Removes stale sequences and adds newly added sequences from the > publisher to pg_subscription_rel. > - Resets all sequences in pg_subscription_rel to 'init' state. > - Initiates sequence synchronization for all sequences by sequence > sync worker as listed in subscription creation process. Here is an updated patch with a few fixes to remove an unused function, changed a few references of table to sequence and added one CHECK_FOR_INTERRUPTS in the sequence sync worker loop. Regards, Vignesh