Re: Conflict detection for update_deleted in logical replication
Amit Kapila <amit.kapila16@gmail.com>
On Tue, Sep 24, 2024 at 2:35 AM Masahiko Sawada <sawada.mshk@gmail.com> wrote: > > > > > As each apply worker needs a separate slot to retain deleted rows, the > > requirement for slots will increase. The other possibility is to > > maintain one slot by launcher or some other central process that > > traverses all subscriptions, remember the ones marked with > > retain_dead_rows (let's call this list as retain_sub_list). Then using > > running_transactions get the oldest running_xact, and then get the > > remote flush location from the other node (publisher node) and store > > those as candidate values (candidate_xmin and > > candidate_remote_wal_lsn) in slot. We can probably reuse existing > > candidate variables of the slot. Next, we can check the remote_flush > > locations from all the origins corresponding in retain_sub_list and if > > all are ahead of candidate_remote_wal_lsn, we can update the slot's > > xmin to candidate_xmin. > > Does it mean that we use one candiate_remote_wal_lsn in a slot for all > subscriptions (in retain_sub_list)? IIUC candiate_remote_wal_lsn is a > LSN of one of publishers, so other publishers could have completely > different LSNs. How do we compare the candidate_remote_wal_lsn to > remote_flush locations from all the origins? > This should be an array/list with one element per publisher. We can copy candidate_xmin to actual xmin only when the candiate_remote_wal_lsn's corresponding to all publishers have been applied aka their remote_flush locations (present in origins) are ahead. The advantages I see with this are (a) reduces the number of slots required to achieve the retention of deleted rows for conflict detection, (b) in some cases we can avoid sending messages to the publisher because with this we only need to send message to a particular publisher once rather than by all the apply workers corresponding to same publisher node. -- With Regards, Amit Kapila.
Commits
-
Fix intermittent BF failures in 035_conflicts.
- 0f42206531b3 19 (unreleased) landed
-
Resume conflict-relevant data retention automatically.
- 0d48d393d465 19 (unreleased) landed
-
Fix intermittent test failure introduced in 6456c6e2c4.
- 01d793698f59 19 (unreleased) landed
-
Fix Coverity issue reported in commit a850be2fe.
- 5ac3c1ac22cb 19 (unreleased) landed
-
Add test to prevent premature removal of conflict-relevant data.
- 6456c6e2c4ad 19 (unreleased) landed
-
Post-commit review fixes for 228c370868.
- 1f7e9ba3ac4e 19 (unreleased) landed
-
Add max_retention_duration option to subscriptions.
- a850be2fe653 19 (unreleased) landed
-
Detect and report update_deleted conflicts.
- fd5a1a0c3e56 19 (unreleased) landed
-
Preserve conflict-relevant data during logical replication.
- 228c37086855 19 (unreleased) landed
-
Integrate FullTransactionIds deeper into two-phase code
- 62a17a92833d 19 (unreleased) cited
-
Improve checks for GUC recovery_target_timeline
- fd7d7b719137 19 (unreleased) cited
-
Prevent excessive delays before launching new logrep workers.
- fd519419c948 18.0 cited
-
Keep WAL segments by slot's last saved restart LSN
- ca307d5cec90 18.0 cited
-
Rework some code handling pg_subscription data in psql and pg_dump
- 08691ea958c2 18.0 cited
-
Use generateClonedIndexStmt to propagate CREATE INDEX to partitions.
- 68dfecbef210 18.0 cited