| From: | Alvaro Herrera <alvherre(at)kurilemu(dot)de> |
|---|---|
| To: | Antonin Houska <ah(at)cybertec(dot)at> |
| Cc: | Rui Zhao <zhaorui126(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, pgsql-hackers(at)lists(dot)postgresql(dot)org, Mihail Nikalayeu <mihailnikalayeu(at)gmail(dot)com> |
| Subject: | Re: Race conditions in logical decoding |
| Date: | 2026-09-18 12:28:55 |
| Message-ID: | aq0sA8aF8q6kTmJM@alvherre.pgsql |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On 2026-Sep-17, Antonin Houska wrote:
> > + for (int i = 0; i < nrunning; i++)
> > + {
> > + TransactionId running_xid = running->xids[i];
> > +
> > + if (bsearch(&running_xid, snap->xip, snap->xcnt,
> > + sizeof(TransactionId), xidComparator) != NULL)
> > + XactLockTableWait(running_xid, NULL, NULL, XLTW_None);
> > + }
> > + }
>
> I don't understand why you check all transactions in procarray, instead of
> only those in snap->xip.
Hmm, but he does: for all the transactions that are running, only those
that are found by bsearch() in the snap->xip array are waited for. Is
that not what we want?
I guess we could do it the other way around: iterate for each item on
snap->xip and search for those in running->xids. Is that what you
suggest?
We don't know offhand which array is largest; it would be better to
iterate on the smaller one and bsearch the largest. (Or maybe if both
are sorted, scan them simultaneously.) I don't find any reference to
say that running_xid is sorted.
I don't understand these two paragraphs:
* A subtransaction is covered by its top-level transaction, which is in
* snap->xip as well, or was purged from it because it is below xmin and
* thus finished long ago.
*
* Historic snapshots do not need this: between xmin and xmax they rely on
* xip alone, and transactions below xmin had left the procarray by the
* time the xl_running_xacts record that set xmin was written.
--
Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/
"After a quick R of TFM, all I can say is HOLY CR** THAT IS COOL! PostgreSQL was
amazing when I first started using it at 7.2, and I'm continually astounded by
learning new features and techniques made available by the continuing work of
the development team."
Berend Tober, http://archives.postgresql.org/pgsql-hackers/2007-08/msg01009.php
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Daniel Gustafsson | 2026-09-18 12:51:04 | Re: Stabilize and shorten test_checksums/013_rewind test |
| Previous Message | solai v | 2026-09-18 12:09:38 | Re: Use correct collation in pg_trgm |