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
- v20241031-0002-Introduce-ALL-SEQUENCES-support-for-Postgr.patch (text/x-patch) patch v20241031-0002
- v20241031-0001-Introduce-pg_sequence_state-function-for-e.patch (text/x-patch) patch v20241031-0001
- v20241031-0005-Documentation-for-sequence-synchronization.patch (text/x-patch) patch v20241031-0005
- v20241031-0003-Reorganize-tablesync-Code-and-Introduce-sy.patch (text/x-patch) patch v20241031-0003
- v20241031-0004-Enhance-sequence-synchronization-during-su.patch (text/x-patch) patch v20241031-0004
On Thu, 24 Oct 2024 at 04:24, Masahiko Sawada <sawada.mshk@gmail.com> wrote: > > Here are comments on the 0001 and 0002 patches: > > 0001 patch: > > read_seq_tuple() reads a buffer and acquires a lock on it, and the > buffer is returned to the caller while being locked. So I think it's > possible for the caller to get the page LSN even without changes. > Since pg_sequence_state() is the sole caller that requests lsn_ret to > be set, I think the changes of read_seq_tuples() is not necessarily > necessary. Modified > 0002 patch: > + Assert(all_tables && *all_tables == false); > + Assert(all_sequences && *all_sequences == false); > > I think it's better to set both *all_tables and *all_sequence to false > at the beginning of the function to ensure this function works as > expected regardless of their initial values. Modified > --- > appendPQExpBufferStr(query, > "SELECT p.tableoid, p.oid, p.pubname, " > "p.pubowner, " > - "p.puballtables, p.pubinsert, > p.pubupdate, p.pubdelete, p.pubtruncate, p.pubviaroot " > + "p.puballtables, false as > p.puballsequences, p.pubinsert, p.pubupdate, p.pubdelete, > p.pubtruncate, p.pubviaroot " > "FROM pg_publication p"); > else if (fout->remoteVersion >= 110000) > appendPQExpBufferStr(query, > "SELECT p.tableoid, p.oid, p.pubname, " > "p.pubowner, " > - "p.puballtables, p.pubinsert, > p.pubupdate, p.pubdelete, p.pubtruncate, false AS pubviaroot " > + "p.puballtables, false as > p.puballsequences, p.pubinsert, p.pubupdate, p.pubdelete, > p.pubtruncate, false AS pubviaroot " > "FROM pg_publication p"); > else > appendPQExpBufferStr(query, > "SELECT p.tableoid, p.oid, p.pubname, " > "p.pubowner, " > - "p.puballtables, p.pubinsert, > p.pubupdate, p.pubdelete, false AS pubtruncate, false AS pubviaroot " > + "p.puballtables, false as > p.puballsequences, p.pubinsert, p.pubupdate, p.pubdelete, false AS > pubtruncate, false AS pubviaroot " > "FROM pg_publication p"); > > The column name should be puballsequences, not p.puballsequences. Modified > --- > IIUC the changes of describeOneTableDetails() includes two kinds of > changes: refactoring to use printTable() instead of printQuery(), and > adding publications that includes the sequence. Is the first > refactoring necessary for the second change? If not, should it be done > in a separate patch? We are adding publication titles as footers to the sequence description, each with different publication names. Since the number of publications is unknown in advance, we will first determine the total number of publications, then allocate the necessary size for the footers. We will append footers[0] with either 'Owned by' or 'Sequence for identity column,' followed by the publication titles. Additionally, these will be subject to version checks. In this case, using printTable instead of printQuery is preferable, as it simplifies the code. The attached patch has the changes for the fixes. Regards, Vignesh