Re: [HACKERS] logical decoding of two-phase transactions

From: Ajin Cherian <itsajin(at)gmail(dot)com>
To: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Cc: Peter Smith <smithpb2250(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [HACKERS] logical decoding of two-phase transactions
Date: 2021-03-20 01:37:22
Message-ID: CAFPTHDaP1A8WVrOmS_Cx+SmLuvtguq7KOp=zbrSMqHi4BOSsiA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Mar 20, 2021 at 1:35 AM Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:

> On Fri, Mar 19, 2021 at 5:03 AM Ajin Cherian <itsajin(at)gmail(dot)com> wrote:
> >
> > Missed the patch - 0001, resending.
> >
>
>
> @@ -538,10 +550,21 @@ CreateDecodingContext(XLogRecPtr start_lsn,
> ..
> + /* Set two_phase_at LSN only if it hasn't already been set. */
> + if (ctx->twophase && !MyReplicationSlot->data.two_phase_at)
> + {
> + MyReplicationSlot->data.two_phase_at = start_lsn;
> + slot->data.two_phase = true;
> + ReplicationSlotMarkDirty();
> + ReplicationSlotSave();
> + SnapBuildSetTwoPhaseAt(ctx->snapshot_builder, start_lsn);
> + }
>
> What if the walsender or apply worker restarts after setting
> two_phase_at/two_phase here and updating the two_phase state in
> pg_subscription? Won't we need to set SnapBuildSetTwoPhaseAt after
> restart as well?
>

After a restart, two_phase_at will be set by calling
AllocateSnapshotBuilder with two_phase_at

@@ -207,7 +207,7 @@ StartupDecodingContext(List *output_plugin_options,
ctx->reorder = ReorderBufferAllocate();
ctx->snapshot_builder =
AllocateSnapshotBuilder(ctx->reorder, xmin_horizon, start_lsn,
- need_full_snapshot, slot->data.initial_consistent_point);
+ need_full_snapshot, slot->data.two_phase_at);

and then in AllocateSnapshotBuilder:

@@ -309,7 +306,7 @@ AllocateSnapshotBuilder(ReorderBuffer *reorder,
builder->initial_xmin_horizon = xmin_horizon;
builder->start_decoding_at = start_lsn;
builder->building_full_snapshot = need_full_snapshot;
- builder->initial_consistent_point = initial_consistent_point;
+ builder->two_phase_at = two_phase_at;

regards,
Ajin Cherian
Fujitsu Australia

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Smith 2021-03-20 01:55:25 Re: [HACKERS] logical decoding of two-phase transactions
Previous Message Hannu Krosing 2021-03-20 00:31:13 Re: shared memory stats: high level design decisions: consistency, dropping