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