RE: Conflict detection for update_deleted in logical replication
Zhijie Hou (Fujitsu) <houzj.fnst@fujitsu.com>
Attachments
- v46-0005-Allow-altering-retain_conflict_info-for-enabled-.patch (application/octet-stream) patch v46-0005
- v46-0001-Preserve-conflict-relevant-data-during-logical-r.patch (application/octet-stream) patch v46-0001
- v46-0002-Introduce-a-new-GUC-max_conflict_retention_durat.patch (application/octet-stream) patch v46-0002
- v46-0003-Re-create-the-replication-slot-if-the-conflict-r.patch (application/octet-stream) patch v46-0003
- v46-0004-Support-the-conflict-detection-for-update_delete.patch (application/octet-stream) patch v46-0004
On Wed, Jul 2, 2025 at 2:03 PM Zhijie Hou (Fujitsu) wrote: > > On Tue, Jul 1, 2025 at 6:10 PM Zhijie Hou (Fujitsu) wrote: > > Here is V45 patch set. > > With the main patch set now stable, I am summarizing the performance tests > conducted before for reference. > > In earlier tests [1], we confirmed that in a pub-sub cluster with high workload > on the publisher (via pgbench), the patch had no impact on TPS (Transactions > Per Second) on the publisher. This indicates that the modifications to the > walsender responsible for replying to publisher status do not introduce > noticeable overhead. > > Additionally, we confirmed that the patch, with its latest mechanism for > dynamically tuning the frequency of advancing slot.xmin, does not affect TPS > on the subscriber when minimal changes occur on the publisher. This test[2] > involved creating a pub-sub cluster and running pgbench on the subscriber to > monitor TPS. It further suggests that the logic for maintaining non-removable > xid in the apply worker does not introduce noticeable overhead for concurrent > user DMLs. > > Furthermore, we tested running pgbench on both publisher and subscriber[3]. > Some regression was observed in TPS on the subscriber, because workload on > the publisher is pretty high and the apply workers must wait for the amount of > transactions with earlier timestamps to be applied and flushed before > advancing the non-removable XID to remove dead tuples. This is the expected > behavior of this approach since the patch's main goal is to retain dead tuples > for reliable conflict detection. > > When discussing the regression, we considered providing a workaround for > users to recover from the regression (the 0002 of the latest patch set). We > introduces a GUC option max_conflict_retention_duration, designed to prevent > excessive accumulation of dead tuples when subscription with > retain_conflict_info enabled is present and the apply worker cannot catch up > with the publisher's workload. In short, the conflict detection replication slot > will be invalidated if lag time exceeds the specified GUC value. > > In performance tests[4], we confirmed that the slot would be invalidated as > expected when the workload on the publisher was high, and it would not get > invalidated anymore after reducing the workload. This shows even if the slot > has been invalidated once, users can continue to detect the update_deleted > conflict by reduce the workload on the publisher. > > The design of the patch set was not changed since the last performance test; > only some code enhancements have been made. Therefore, I think the results > and findings from the previous performance tests are still valid. However, if > necessary, we can rerun all the tests on the latest patch set to verify the same. During local testing, I discovered a bug caused by my oversight in assigning the new xmin to slot.effective, which resulted in dead tuples remaining non-removable until restart. I apologize for the error and have provided corrected patches. Kindly use the latest patch set for performance testing. 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