Re: Race conditions in logical decoding

Поиск
Список
Период
Сортировка
Искать
От
Antonin Houska
Тема
Re: Race conditions in logical decoding
Дата
Msg-id
12834.1789745009@localhost
Ответ на
Список
Дерево обсуждения
Race conditions in logical decoding Antonin Houska <ah@cybertec.at>
Re: Race conditions in logical decoding Antonin Houska <ah@cybertec.at>
Re: Race conditions in logical decoding Álvaro Herrera <alvherre@kurilemu.de>
Re: Race conditions in logical decoding Antonin Houska <ah@cybertec.at>
Re: Race conditions in logical decoding Álvaro Herrera <alvherre@kurilemu.de>
Re: Race conditions in logical decoding Antonin Houska <ah@cybertec.at>
Re: Race conditions in logical decoding Andres Freund <andres@anarazel.de>
Re: Race conditions in logical decoding Álvaro Herrera <alvherre@kurilemu.de>
Re: Race conditions in logical decoding Antonin Houska <ah@cybertec.at>
Re: Race conditions in logical decoding Mihail Nikalayeu <mihailnikalayeu@gmail.com>
Re: Race conditions in logical decoding Antonin Houska <ah@cybertec.at>
Re: Race conditions in logical decoding Mihail Nikalayeu <mihailnikalayeu@gmail.com>
Re: Race conditions in logical decoding Antonin Houska <ah@cybertec.at>
Re: Race conditions in logical decoding Álvaro Herrera <alvherre@kurilemu.de>
Re: Race conditions in logical decoding Álvaro Herrera <alvherre@kurilemu.de>
Alvaro Herrera  wrote:

> On 2026-Sep-18, Antonin Houska wrote:
> 
> > Maybe I miss the point, but what's wrong about modifying the existing loop
> > that inverts the meaning of the ->xip array
> > 
> > 	/*
> > 	 * snapbuild.c builds transactions in an "inverted" manner, which means it
> > 	 * stores committed transactions in ->xip, not ones in progress. Build a
> > 	 * classical snapshot by marking all non-committed transactions as
> > 	 * in-progress. This can be expensive.
> > 	 */
> > 	for (xid = snap->xmin; NormalTransactionIdPrecedes(xid, snap->xmax);)
> > 	{
> > 		...
> > 	}
> > 
> > by calling XactLockTableWait() for each XID we find in the array (i.e. each
> > committed transaction)?
> 
> Ah, you mean something like the attached quick POC?  This does pass the
> two tests that Rui wrote, also attached.  (I didn't test Zhijie's, which
> AFAICT is written to pass with the bug and fail without it.)

Yes, I mean checking if those transactions have really ended.

Regarding [1], perhaps the idea is to avoid calling XactLockTableWait() if the
transaction is no longer in procarray. I'm not sure it's a problem to call
that function (possibly many times) for transactions that are no longer
running. (GetRunningTransactionData() is not free either.)

And regarding the deadlock with synchronous replica, my understanding is that
we avoid it by waiting in SnapBuildInitialSnapshot() instead of in
SnapBuildBuildSnapshot().

[1] https://www.postgresql.org/message-id/CAHWVJhHXyLtS-8mdL9WhEWfsERb%3DFN7JdPD0GYAXgTmCnqbYGw%40mail.gmail.com

-- 
Antonin Houska
Web: https://www.cybertec-postgresql.com


В списке pgsql-hackers по дате отправления
От: zengxx
Дата:
От: Nathan Bossart
Дата:
FAQ