Question about initial logical decoding snapshot

From: Chong Wang <chongwa(at)vmware(dot)com>
To: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Question about initial logical decoding snapshot
Date: 2022-12-30 18:26:46
Message-ID: SA1PR05MB8676BED58D78CB10507227F1D4F09@SA1PR05MB8676.namprd05.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi hackers.
I'm studying the source code about creation of initial logical decoding snapshot. What confused me is that why must we process 3 xl_running_xacts before we get to the consistent state. I think we only need 2 xl_running_xacts.
I think we can get to consistent state when we meet the 2nd xl_running_xact with its oldestRunningXid > 1st xl_running_xact's nextXid, this means the active transactions in 1st xl_running_xact all had commited, and we have all the logs of transactions who will commit afterwards, so there is consistent state in this time point and we can export a snapshot.
I had read the discussion in [0] and the comment of commit '955a684', but I haven't got a detailed explanation about why we need 4 stages during creation of initial logical decoding snapshot but not 3 stages.
My rencent job is relevant to logical decoding so I want to figure this problem out, I'm very grateful if you can answer me, thanks.

[0] https://www.postgresql.org/message-id/flat/f37e975c-908f-858e-707f-058d3b1eb214%402ndquadrant.com

--
Best regards
Chong Wang
Greenplum DataFlow team

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Nathan Bossart 2022-12-30 18:32:57 Re: Simplify standby state machine a bit in WaitForWALToBecomeAvailable()
Previous Message Joseph Koshakow 2022-12-30 17:17:36 Re: Infinite Interval