RE: Conflict detection for update_deleted in logical replication

Zhijie Hou (Fujitsu) <houzj.fnst@fujitsu.com>

From: "Zhijie Hou (Fujitsu)" <houzj.fnst@fujitsu.com>
To: Nisha Moond <nisha.moond412@gmail.com>
Cc: Amit Kapila <amit.kapila16@gmail.com>, Dilip Kumar <dilipbalaut@gmail.com>, Masahiko Sawada <sawada.mshk@gmail.com>, shveta malik <shveta.malik@gmail.com>, "Hayato Kuroda (Fujitsu)" <kuroda.hayato@fujitsu.com>, pgsql-hackers <pgsql-hackers@postgresql.org>, vignesh C <vignesh21@gmail.com>
Date: 2025-08-21T08:31:22Z
Lists: pgsql-hackers

Attachments

On Thursday, August 21, 2025 3:47 PM Nisha Moond <nisha.moond412@gmail.com> wrote:
> 
> On Wed, Aug 20, 2025 at 12:12 PM Zhijie Hou (Fujitsu)
> <houzj.fnst@fujitsu.com> wrote:
> >
> > I agree. Here is V63 version which implements this approach.
> >
> 
> Thank you Hou-san for the patches. Here are couple of comments:
> 
> 1) Once retention is stopped for all subscriptions and conflict_slot.xmin is
> reset to NULL, we are no longer retaining dead tuples. In that case, the warning
> shown during subscription disable looks misleading.
> 
> For example sub has already stopped the retention and when disabled -
> postgres=# alter subscription sub1 disable;
> WARNING:  deleted rows to detect conflicts would not be removed until the
> subscription is enabled
> HINT:  Consider setting retain_dead_tuples to false.
> ALTER SUBSCRIPTION
> 
> I think we should check if retention is active or not here.
> 
> 2) Regarding the logic in the launcher for advancing the slot’s xmin:
> Consider a case where two subscriptions exist, and one of them is disabled
> after it has already stopped retention.
> Example subscriptions in state:
> ... 
> Here, sub2 is disabled, and since subretentionactive = 'f', it is not retaining
> dead tuples anymore. But, the current launcher logic still blocks xmin
> advancement as one of the subscriptions with retain_dead_tuples is disabled.
> I think the launcher should consider the subretentionactive value and the xmin
> should be allowed to advance. Thoughts?

I agree that retentionactive needs to be checked in the cases mentioned above.
Here is the V64 patch set addressing this concern. This version also resolves
the bug reported by Shveta[1], where retention could not resume and was stuck
waiting for the publisher status.

In addition, I also improved the comments related to the new phases and
retentionactive flag.

[1] https://www.postgresql.org/message-id/CAJpy0uCP7x_pdVysYohvrjpk0Vtmk36%2BXfnC_DOPiegekxfBLA%40mail.gmail.com

Best Regards,
Hou zj



Commits

  1. Fix intermittent BF failures in 035_conflicts.

  2. Resume conflict-relevant data retention automatically.

  3. Fix intermittent test failure introduced in 6456c6e2c4.

  4. Fix Coverity issue reported in commit a850be2fe.

  5. Add test to prevent premature removal of conflict-relevant data.

  6. Post-commit review fixes for 228c370868.

  7. Add max_retention_duration option to subscriptions.

  8. Detect and report update_deleted conflicts.

  9. Preserve conflict-relevant data during logical replication.

  10. Integrate FullTransactionIds deeper into two-phase code

  11. Improve checks for GUC recovery_target_timeline

  12. Prevent excessive delays before launching new logrep workers.

  13. Keep WAL segments by slot's last saved restart LSN

  14. Rework some code handling pg_subscription data in psql and pg_dump

  15. Use generateClonedIndexStmt to propagate CREATE INDEX to partitions.