Re: Conflict detection for update_deleted in logical replication
Amit Kapila <amit.kapila16@gmail.com>
On Fri, Jan 3, 2025 at 12:06 PM Masahiko Sawada <sawada.mshk@gmail.com> wrote: > > I have one comment on the 0001 patch: > > + /* > + * The changes made by this and later transactions are still > non-removable > + * to allow for the detection of update_deleted conflicts when applying > + * changes in this logical replication worker. > + * > + * Note that this info cannot directly protect dead tuples from being > + * prematurely frozen or removed. The logical replication launcher > + * asynchronously collects this info to determine whether to advance the > + * xmin value of the replication slot. > + * > + * Therefore, FullTransactionId that includes both the > transaction ID and > + * its epoch is used here instead of a single Transaction ID. This is > + * critical because without considering the epoch, the transaction ID > + * alone may appear as if it is in the future due to transaction ID > + * wraparound. > + */ > + FullTransactionId oldest_nonremovable_xid; > > The last paragraph of the comment mentions that we need to use > FullTransactionId to properly compare XIDs even after the XID > wraparound happens. But once we set the oldest-nonremovable-xid it > prevents XIDs from being wraparound, no? I mean that workers' > oldest-nonremovable-xid values and slot's non-removal-xid (i.e., its > xmin) are never away from more than 2^31 XIDs. > I also think that the slot's non-removal-xid should ensure that we never allow xid to advance to a level where it can cause a wraparound for the oldest-nonremovable-xid value stored in each worker because the slot's value is the minimum of all workers. Now, if both of us are missing something then it is probably better to write some more detailed comments as to how this can happen. Along the same lines, I was thinking whether RetainConflictInfoData->last_phase_at should be FullTransactionId but I think that is correct because we can't stop wraparound from happening on remote_node, right? -- 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