RE: Conflict detection for update_deleted in logical replication
Zhijie Hou (Fujitsu) <houzj.fnst@fujitsu.com>
Attachments
- v59-0002-Resume-retaining-the-information-for-conflict-de.patch (application/octet-stream) patch v59-0002
- v59-0001-Introduce-a-new-GUC-max_conflict_retention_durat.patch (application/octet-stream) patch v59-0001
On Friday, August 8, 2025 2:34 PM shveta malik <shveta.malik@gmail.com> wrote: > > On Thu, Aug 7, 2025 at 10:10 AM Zhijie Hou (Fujitsu) > <houzj.fnst@fujitsu.com> wrote: > > > > On Tuesday, August 5, 2025 10:09 AM Zhijie Hou (Fujitsu) > <houzj.fnst@fujitsu.com> wrote: > > > Here is V57 patch set which addressed most of comments. > > > > > > In this version, I also fixed a bug that the apply worker continued > > > to find dead tuples even if it has already stop retaining dead tuples. > > > > Here is a V58 patch set which improved few things by internal review: > > > > 0001: > > > > Thank You for the patches, please find a few comments on 001 alone: Thanks for the comments. > > 1) > + /* > + * Return if the wait time has not exceeded the maximum limit > + * (max_conflict_retention_duration). > + */ > + if (!TimestampDifferenceExceeds(rdt_data->candidate_xid_time, now, > + max_conflict_retention_duration + > + rdt_data->table_sync_wait_time)) > > We can add comments here as in why we are adding table-sync time to > max_conflict_retention_duration. Added. > > 2) > relmutex comment says: > > /* Used for initial table synchronization. */ > Oid relid; > char relstate; > XLogRecPtr relstate_lsn; > slock_t relmutex; > > We shall update this comment as now we are using it for other purposes. Also > name is specific to relation (due to originally created for table-sync case). We > can rename it to be more general so that it can be used for oldest-xid access > purposes as well. Changed the name and added comments. > > 3) > + Assert(TransactionIdIsValid(rdt_data->candidate_xid)); > + Assert(rdt_data->phase == RDT_WAIT_FOR_PUBLISHER_STATUS || > + rdt_data->phase == RDT_WAIT_FOR_LOCAL_FLUSH); > + > + if (!max_conflict_retention_duration) > + return false; > > Shall we move 'max_conflict_retention_duration' NULL check as the first step. > Or do you think it will be better to move it to the caller before > should_stop_conflict_info_retention is invoked? I think these Asserts are good to have, even if the GUC is not specified, so I kept the current style. > > 4) > + The information useful for conflict detection is no longer retained if > + all apply workers associated with the subscriptions, where > + <literal>retain_dead_tuples</literal> is enabled, confirm that the > + retention duration exceeded the > + <literal>max_conflict_retention_duration</literal>. To re-enable > + retention, you can disable <literal>retain_dead_tuples</literal> and > + re-enable it after confirming this replication slot has been dropped. > > But the replication slot will not be dropped unless all the subscriptions have > disabled retain_dead_tuples. So shall the above doc somehow mention this > part as well otherwise it could be misleading for users. Added. > 5) > pg_stat_subscription_stats: retain_dead_tuples > > Can it cause confusion as both subscription's parameter and > pg_stat_subscription_stats's column have the same name while may have > different values. Shall the stats one be named as > 'effective_retain_dead_tuples'? I think the prefix "effective_" is typically used for non-boolean options (such as effective_cache_size or effective_io_concurrency). So, I opted for the name "dead_tuple_retention_active" as it aligns with some existing names like "row_security_active." Here is V59 patch set which addressed above comments in 0001. 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