Re: Question about initial logical decoding snapshot
От | Amit Kapila |
---|---|
Тема | Re: Question about initial logical decoding snapshot |
Дата | |
Msg-id | CAA4eK1LW4th+ZChDh5Vp5KYspA189KcdnAj9V2N-o-+yceTJxg@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Question about initial logical decoding snapshot (Amit Kapila <amit.kapila16@gmail.com>) |
Список | pgsql-hackers |
On Tue, Jan 3, 2023 at 4:44 PM Amit Kapila <amit.kapila16@gmail.com> wrote: > > On Fri, Dec 30, 2022 at 11:57 PM Chong Wang <chongwa@vmware.com> wrote: > > > > I'm studying the source code about creation of initial logical decoding snapshot. What confused me is that why must weprocess 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'snextXid, this means the active transactions in 1st xl_running_xact all had commited, and we have all thelogs of transactions who will commit afterwards, so there is consistent state in this time point and we can export a snapshot. > > > > Yeah, we will have logs for all transactions in such a case but I > think we won't have a valid snapshot by that time. Consider a case > that there are two transactions 723,724 in the 2nd xl_running_xact > record for which we have waited to finish and then consider that point > as a consistent point and exported that snapshot. It is quite possible > that by that time the commit record of one or more of those xacts (say > 724) wouldn't have been encountered by decoding process and that means > it won't be recorded in the xip list of the snapshot (we do that in > DecodeCommit->SnapBuildCommitTxn). So, during export in function > SnapBuildInitialSnapshot(), we will consider 723 as committed and 724 > as running. This could not lead to inconsistent data on the client > side that imports such a snapshot and use it for copy and further > replicating the other xacts. > > OTOH, currently, before marking snapshot state as consistent we wait > for these xacts to finish and for another xl_running_xact where > oldestRunningXid >= builder->next_phase_at to appear which means the > commit for both 723 and 724 would have appeared in the snapshot. > > Does that makes sense to you or am, I missing something here? > You can also refer to the discussion in the thread [1] which is related to your question. [1] - https://www.postgresql.org/message-id/c94be044-818f-15e3-1ad3-7a7ae2dfed0a%40iki.fi -- With Regards, Amit Kapila.
В списке pgsql-hackers по дате отправления: