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
On Tue, 20 May 2025 at 09:54, shveta malik <shveta.malik@gmail.com> wrote: > > On Tue, May 20, 2025 at 8:35 AM Nisha Moond <nisha.moond412@gmail.com> wrote: > > > > > > > > Thanks for the comments, these are handled in the attached v20250516 > > > version patch. > > > > > > > Thanks for the patches. Here are my review comments - > > > > Patch-0004: src/backend/replication/logical/sequencesync.c > > > > The sequence count logic using curr_seq in copy_sequences() seems buggy. > > Currently, curr_seq is incremented based on the number of tuples > > received from the publisher inside the inner while loop. > > This means it's counting the number of sequences returned by the > > publisher, not the number of sequences processed locally. This can > > lead to two issues: > > > > 1) Repeated syncing of sequences: > > If some sequences are missing on the publisher, curr_seq will reflect > > fewer items than expected, and subsequent batches may reprocess > > already-synced sequences. Because next batch will use curr_seq to get > > values from the list as - > > > > seqinfo = (LogicalRepSequenceInfo *) > > lfirst(list_nth_cell(remotesequences, curr_seq + i)); > > > > Example: > > For 110 sequences(s1 to s110), if 5 (s1 to s5) are missing on the > > publisher in the first batch, curr_seq = 95. In the next cycle, we > > resync s95 to s99. > > ~~~~ > > > > 2) Risk of sequencesync worker getting stuck in infinite loop > > > > Consider a case where remotesequences has 10 sequences (s1–s10) need > > syncing, and concurrently s9, s10 are deleted on the publisher. > > > > Cycle 1: > > Publisher returns s1–s8. So curr_seq = 8. > > > > Cycle 2: > > Publisher query returns zero rows (as s9, s10 no longer exist). > > curr_seq stays at 8 and never advances. > > > > This causes the while (curr_seq < total_seq) loop to run forever. > > ~~~~ > > > > I think curr_seq should be incremented by batch_seq_count just > > outside the inner while loop. > > > > I faced the similar issue while testing. I think it is due to the > code-logic issue pointed out by Nisha above. Yes, it is the same issue, this has been fixed in the v20250521 version posted at [1]. [1] - https://www.postgresql.org/message-id/CALDaNm2ZgyYbowqZJfpkpRV_tev5o-rqpkLDkp496ku15Tdsqw%40mail.gmail.com Regards, Vignesh