RE: Conflict detection for update_deleted in logical replication
Zhijie Hou (Fujitsu) <houzj.fnst@fujitsu.com>
Attachments
- v16-0006-Add-a-tap-test-to-verify-the-new-slot-xmin-mecha.patch (application/octet-stream) patch v16-0006
- v16-0001-Maintain-the-oldest-non-removeable-tranasction-I.patch (application/octet-stream) patch v16-0001
- v16-0002-Dynamically-adjust-xid-advancement-interval.patch (application/octet-stream) patch v16-0002
- v16-0003-Maintain-the-replication-slot-in-logical-launche.patch (application/octet-stream) patch v16-0003
- v16-0004-Support-the-conflict-detection-for-update_delete.patch (application/octet-stream) patch v16-0004
- v16-0005-Add-a-detect_update_deleted-option-to-subscripti.patch (application/octet-stream) patch v16-0005
On Wednesday, December 11, 2024 3:34 PM Zhijie Hou (Fujitsu) <houzj.fnst@fujitsu.com> wrote:
>
> On Wednesday, December 11, 2024 1:06 PM Amit Kapila
> <amit.kapila16@gmail.com> wrote:
> > On Fri, Dec 6, 2024 at 1:28 PM Zhijie Hou (Fujitsu)
> > <houzj.fnst@fujitsu.com>
> > wrote:
> > >
> > > On Thursday, December 5, 2024 6:00 PM Amit Kapila
> > <amit.kapila16@gmail.com> wrote:
> > > >
> > > >
> > > > A few more comments:
> > > > 1.
> > > > +static void
> > > > +wait_for_local_flush(RetainConflictInfoData *data)
> > > > {
> > > > ...
> > > > +
> > > > + data->phase = RCI_GET_CANDIDATE_XID;
> > > > +
> > > > + maybe_advance_nonremovable_xid(data);
> > > > +}
> > > >
> > > > Isn't it better to reset all the fields of data before the next
> > > > round of GET_CANDIDATE_XID phase? If we do that then we don't need
> > > > to reset
> > > > data->remote_lsn = InvalidXLogRecPtr; and data->last_phase_at =
> > > > InvalidFullTransactionId; individually in
> > > > request_publisher_status() and
> > > > get_candidate_xid() respectively. Also, it looks clean and logical
> > > > to me unless I am missing something.
> > >
> > > The remote_lsn was used to determine whether a status is received,
> > > so was reset each time in request_publisher_status. To make it more
> > > straightforward, I added a new function parameter 'status_received',
> > > which would be set to true when calling
> > > maybe_advance_nonremovable_xid() on receving the status. After this
> > change, there is no need to reset the remote_lsn.
> > >
> >
> > As part of the above comment, I had asked for three things (a) avoid
> > setting
> > data->remote_lsn = InvalidXLogRecPtr; in request_publisher_status();
> > data->(b)
> > avoid setting data->last_phase_at =InvalidFullTransactionId; in
> > get_candidate_xid(); (c) reset data in
> > wait_for_local_flush() after wait is over. You only did (a) in the
> > patch and didn't mention anything about (b) or (c). Is that intentional? If so,
> what is the reason?
>
> I think I misunderstood the intention, so will address in next version.
>
> >
> > *
> > +static bool
> > +can_advance_nonremovable_xid(RetainConflictInfoData *data) {
> > +
> >
> > Isn't it better to make this an inline function as it contains just one check?
>
> Agreed. Will address in next version.
>
> >
> > *
> > + /*
> > + * The non-removable transaction ID for a subscription is centrally
> > + * managed by the main apply worker.
> > + */
> > + if (!am_leader_apply_worker())
> >
> > I have tried to improve this comment in the attached.
>
> Thanks, will check and merge the next version.
Attach the V16 patch set which addressed above comments.
There is a new 0002 patch where I tried to dynamically adjust the interval for
advancing the transaction ID. Instead of always waiting for
wal_receiver_status_interval, we can start with a short interval and increase
it if there is no activity (no xid assigned on subscriber), but not beyond
wal_receiver_status_interval.
The intention is to more effectively advance xid to avoid retaining too much
dead tuples. My colleague will soon share detailed performance data and
analysis related to this enhancement.
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