Re: GiST VACUUM

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: Andrey Borodin <x4mmm(at)yandex-team(dot)ru>
Cc: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>, Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Костя Кузнецов <chapaev28(at)ya(dot)ru>
Subject: Re: GiST VACUUM
Date: 2019-06-27 21:19:15
Message-ID: 55249fb5-ea9e-0485-ab64-983b3369b131@iki.fi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 27/06/2019 20:15, Andrey Borodin wrote:
> But I have stupid question again, about this code:
>
> https://github.com/x4m/postgres_g/commit/096d5586537d29ff316ca8ce074bbe1b325879ee#diff-754126824470cb8e68fd5e32af6d3bcaR417
>
> nextFullXid = ReadNextFullTransactionId();
> diff = U64FromFullTransactionId(nextFullXid) -
> U64FromFullTransactionId(latestRemovedFullXid);
> if (diff < MaxTransactionId / 2)
> {
> TransactionId latestRemovedXid;
>
> // sleep(100500 hours); latestRemovedXid becomes xid from future
>
> latestRemovedXid = XidFromFullTransactionId(latestRemovedFullXid);
> ResolveRecoveryConflictWithSnapshot(latestRemovedXid,
> xlrec->node);
> }
>
> Do we have a race condition here? Can latestRemovedXid overlap and start to be xid from future?
> I understand that it is purely hypothetical, but still latestRemovedXid is from ancient past already.

Good question. No, that can't happen, because this code is in the WAL
redo function. In a standby, the next XID counter only moves forward
when a WAL record is replayed that advances it, and all WAL records are
replayed serially, so that can't happen when we're in the middle of
replaying this record. A comment on that would be good, though.

When I originally had the check like above in the code that created the
WAL record, it had exactly that problem, because in the master the next
XID counter can advance concurrently.

- Heikki

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2019-06-27 21:21:48 Re: [HACKERS] Regression tests vs existing users in an installation
Previous Message Tom Lane 2019-06-27 20:50:06 Re: [HACKERS] Regression tests vs existing users in an installation