RE: Conflict detection for update_deleted in logical replication
Zhijie Hou (Fujitsu) <houzj.fnst@fujitsu.com>
Attachments
- v1-0001-Stablize-the-tests-in-035_conflicts.patch (application/octet-stream) patch v1-0001
On Monday, September 15, 2025 8:11 PM Amit Kapila <amit.kapila16@gmail.com> wrote: > > On Mon, Sep 15, 2025 at 1:07 PM Zhijie Hou (Fujitsu) > <houzj.fnst@fujitsu.com> wrote: > > > > Thanks, the changes look good to me. I have merged them in V75 patch. > > > > Pushed. I see a BF which is not related with this commit but a previous commit > for the work in this thread. > > See LOGs [1]: > regress_log_035_conflicts > ----------------------------------- > [11:16:47.604](0.015s) not ok 24 - the deleted column is removed > [11:16:47.605](0.002s) # Failed test 'the deleted column is removed' > # at > /home/bf/bf-build/kestrel/HEAD/pgsql/src/test/subscription/t/035_conflict > s.pl > line 562. > > Then the corresponding subscriber LOG: > > 025-09-15 11:16:47.600 CEST [1888170][client backend][1/13:0] INFO: > vacuuming "postgres.public.tab" > 2025-09-15 11:16:47.600 CEST [1888170][client backend][1/13:0] INFO: > finished vacuuming "postgres.public.tab": index scans: 0 > pages: 0 removed, 1 remain, 1 scanned (100.00% of total), 0 eagerly scanned > tuples: 0 removed, 1 remain, 0 are dead but not yet removable tuples missed: 1 > dead from 1 pages not removed due to cleanup lock contention removable > cutoff: 787, which was 0 XIDs old when operation ended ... > > This indicates that the Vacuum is not able to remove the row even after the slot > is advanced because some other background process holds a lock/pin on the > page. I think that is possible because the page was dirty due to apply of update > operation and bgwriter/checkpointer could try to write such a page. > > I'll analyze more tomorrow and share if I have any new findings. I agree with the analysis. I attempted to delete a tuple from a table and, while executing VACUUM(verbose) on this table, I executed a checkpoint concurrently. Using the debugger, I stoped in SyncOneBuffer() after acquiring the page block. This allowed me to reproduce the same log where the deleted row could not be removed: -- tuples: 0 removed, 1 remain, 0 are dead but not yet removable tuples missed: 1 dead from 1 pages not removed due to cleanup lock contention -- I think we can remove the VACUUM for removing the deleted column. We have already confirmed that the replication slot.xmin has advanced, which should be sufficient to prove that the feature works correctly. Best Regards, Hou zj
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