Re: Potential data loss due to race condition during logical replication slot creation - Mailing list pgsql-bugs

From Amit Kapila
Subject Re: Potential data loss due to race condition during logical replication slot creation
Date
Msg-id CAA4eK1JSZnRJmHatGdC1LFiFB=VT2js32rDtpV5_Seoa0nbJpw@mail.gmail.com
Whole thread Raw
In response to RE: Potential data loss due to race condition during logical replication slot creation  ("Hayato Kuroda (Fujitsu)" <kuroda.hayato@fujitsu.com>)
Responses RE: Potential data loss due to race condition during logical replication slot creation  ("Hayato Kuroda (Fujitsu)" <kuroda.hayato@fujitsu.com>)
List pgsql-bugs
On Tue, Mar 19, 2024 at 7:46 AM Hayato Kuroda (Fujitsu)
<kuroda.hayato@fujitsu.com> wrote:
>
> I think the approach was most conservative one which does not have to change
> the version of the snapshot. However, I understood that you wanted to consider
> the optimized solution for HEAD first.
>

Right, let's see if we can have a solution other than always avoiding
restoring snapshots during slot creation even if that is for just
HEAD.

> > See SnapBuildCommitTxn(). Can we avoid this problem if we
> > would have list of all running xacts when we serialize the snapshot by
> > not decoding any xact whose xid lies in that list? If so, one idea to
> > achieve could be that we maintain the highest_running_xid while
> > serailizing the snapshot and then during restore if that
> > highest_running_xid is <= builder->initial_xmin_horizon, then we
> > ignore restoring the snapshot. We already have few such cases handled
> > in SnapBuildRestore().
>
> Based on the idea, I made a prototype. It can pass tests added by others and me.
> How do other think?
>

Won't it be possible to achieve the same thing if we just save
(serialize) the highest xid among all running xacts?

--
With Regards,
Amit Kapila.



pgsql-bugs by date:

Previous
From: "Hayato Kuroda (Fujitsu)"
Date:
Subject: RE: Potential data loss due to race condition during logical replication slot creation
Next
From: ocean_li_996
Date:
Subject: Re:BUG #18369: logical decoding core on AssertTXNLsnOrder()