Re: Logical Replication of sequences
Peter Smith <smithpb2250@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
- PS_NITPICKS_20240808_SEQ_0003.txt (text/plain)
Hi Vignesh, Here are my v20240807-0003 review comments. ====== 1. GENERAL DOCS. IMO the replication of SEQUENCES is a big enough topic that it deserves to have its own section in the docs chapter 31 [1]. Some of the create/alter subscription docs content would stay where it is in, but a new chapter would just tie everything together better. It could also serve as a better place to describe the other sequence replication content like: (a) getting a WARNING for mismatched sequences and how to handle it. (b) how can the user know when a subscription refresh is required to (re-)synchronise sequences (c) pub/sub examples ====== doc/src/sgml/logical-replication.sgml 2. Restrictions Sequence data is not replicated. The data in serial or identity columns backed by sequences will of course be replicated as part of the table, but the sequence itself would still show the start value on the subscriber. If the subscriber is used as a read-only database, then this should typically not be a problem. If, however, some kind of switchover or failover to the subscriber database is intended, then the sequences would need to be updated to the latest values, either by executing ALTER SUBSCRIPTION ... REFRESH PUBLICATION SEQUENCES or by copying the current data from the publisher (perhaps using pg_dump) or by determining a sufficiently high value from the tables themselves. ~ 2a. The paragraph starts by saying "Sequence data is not replicated.". It seems wrong now. Doesn't that need rewording or removing? ~ 2b. Should the info "If, however, some kind of switchover or failover..." be mentioned in the "Logical Replication Failover" section [2], instead of here? ====== doc/src/sgml/ref/alter_subscription.sgml 3. Sequence values may occasionally become out of sync due to updates in the publisher. To verify this, compare the pg_subscription_rel.srsublsn on the subscriber with the page_lsn obtained from the pg_sequence_state for the sequence on the publisher. If the sequence is still using prefetched values, the page_lsn will not be updated. In such cases, you will need to directly compare the sequences and execute REFRESH PUBLICATION SEQUENCES if required. ~ 3a. This whole paragraph may be better put in the new chapter that was suggested earlier in review comment #1. ~ 3b. Is it only "Occasionally"? I expected subscriber-side sequences could become stale quite often. ~ 3c. Is this advice very useful? It's saying if the LSN is different then the sequence is out of date, but if the LSN is not different then you cannot tell. Why not ignore LSN altogether and just advise the user to directly compare the sequences in the first place? ====== Also, there are more minor suggestions in the attached nitpicks diff. ====== [1] https://www.postgresql.org/docs/current/logical-replication.html [2] file:///usr/local/pg_oss/share/doc/postgresql/html/logical-replication-failover.html Kind Regards, Peter Smith. Fujitsu Australia