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
- v20250806-0003-Reorganize-tablesync-Code-and-Introduce-sy.patch (text/x-patch) patch v20250806-0003
- v20250806-0004-Introduce-REFRESH-PUBLICATION-SEQUENCES-fo.patch (text/x-patch) patch v20250806-0004
- v20250806-0001-Enhance-pg_get_sequence_data-function.patch (text/x-patch) patch v20250806-0001
- v20250806-0005-New-worker-for-sequence-synchronization-du.patch (text/x-patch) patch v20250806-0005
- v20250806-0002-Introduce-ALL-SEQUENCES-support-for-Postgr.patch (text/x-patch) patch v20250806-0002
- v20250806-0006-Documentation-for-sequence-synchronization.patch (text/x-patch) patch v20250806-0006
On Fri, 1 Aug 2025 at 16:18, Hayato Kuroda (Fujitsu)
<kuroda.hayato@fujitsu.com> wrote:
>
> Dear Vignesh,
>
> I played with your patch and found something.
>
> 01.
> In LogicalRepSyncSequences() and GetSubscriptionRelations(), there is a possibility
> that the sequence on the subscriber could be dropped before opens that.
> This can cause `could not open relation with OID %u` error, which is not user-friendly.
> Can we avoid that? Even if it is difficult we should add ereport().
Addressed this by taking RowExclusiveLock on the sequence while
preparing the list
> 02.
> ```
> /*
> * Check that our sequencesync worker has permission to insert into
> * the target sequence.
> */
> aclresult = pg_class_aclcheck(RelationGetRelid(sequence_rel), GetUserId(),
> ACL_INSERT);
> if (aclresult != ACLCHECK_OK)
> aclcheck_error(aclresult,
> get_relkind_objtype(sequence_rel->rd_rel->relkind),
> seqname);
> ```
>
> Hmm, but upcoming SetSequence() needs UPDATE privilege. I feel it should be checked.
Modified
> 03.
> Similar with 1, sequences can be dropped just before entering copy_sequences().
> This can cause `cache lookup failed for sequence` error, which cannot be translated.
> Can we avoid that or change the error-function to erport()?
Changed it to log this sequence concurrently dropped
> 04.
> ```
> if (message_level_is_interesting(DEBUG1))
> ereport(DEBUG1,
> errmsg_internal("logical replication synchronization for subscription \"%s\", sequence \"%s.%s\" has finished",
> MySubscription->name,
> seqinfo->nspname,
> seqinfo->seqname));
> ```
>
> I feel no need to add if-statement because we do not touch additional data here.
Modified
> 05.
> ```
> list_free_deep(sequences_to_copy);
> ```
>
> IIUC, this function free's each elements and list itself, but they do no-op for
> attributes of elements. Can we pfree() for seqname and nspname?
Modified
The attached v20250806 version patch has the changes for the same.
Regards,
Vignesh