Re: Usage of epoch in txid_current

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
Cc: Andres Freund <andres(at)anarazel(dot)de>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Alexander Korotkov <a(dot)korotkov(at)postgrespro(dot)ru>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Andrey Borodin <x4mmm(at)yandex-team(dot)ru>
Subject: Re: Usage of epoch in txid_current
Date: 2019-03-27 12:48:20
Message-ID: a7fe7875-1d65-e44d-8709-3f88ae674295@iki.fi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 27/03/2019 13:44, Thomas Munro wrote:
> * I tidied up the code that serialises transaction state. It was
> already hammering round pegs into square holes, and the previous patch
> made that even worse, so I added a new struct
> SerializedTransactionState to do this properly.

Ah, good, it used to be confusing.

> I still need to look into Andres's suggestion about getting rid of
> epoch from various user interfaces and showing 64 bit numbers. I
> should probably also find a place in the relevant README to explain
> this new scheme. I will post follow-up patches for those.

Once we have the FullTransactionId type and basic macros in place, I'm
sure we could tidy up a bunch of code by using them. For example,
TransactionIdInRecentPast() in walsender.c would be simpler, if the
caller dealt with FullTransactionIds rather than xid+epoch. But it makes
sense to do that separately.

> +/*
> + * Advance nextFullXid to the value after a given xid. The epoch is inferred.
> + * This must only be called during recovery or from two-phase start-up code.
> + */
> +void
> +AdvanceNextFullTransactionIdPastXid(TransactionId xid)
> +{
> + FullTransactionId newNextFullXid;
> + TransactionId next_xid;
> + uint32 epoch;
> +
> + /*
> + * It is safe to read nextFullXid without a lock, because this is only
> + * called from the startup process, meaning that no other process can
> + * modify it.
> + */
> + Assert(AmStartupProcess());
> +

This assertion fails on WAL replay in single-user mode:

$ bin/postgres --single -D data postgres
2019-03-27 14:32:35.058 EET [32359] LOG: database system was
interrupted; last known up at 2019-03-27 14:32:18 EET
2019-03-27 14:32:35.144 EET [32359] LOG: database system was not
properly shut down; automatic recovery in progress
2019-03-27 14:32:35.148 EET [32359] LOG: redo starts at 0/15BB7B0
TRAP: FailedAssertion("!((MyAuxProcType == StartupProcess))", File:
"varsup.c", Line: 269)
Aborted

- Heikki

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Adrien NAYRAT 2019-03-27 13:28:21 Re: Log a sample of transactions
Previous Message Dean Rasheed 2019-03-27 12:46:29 Re: BUG #15708: RLS 'using' running as wrong user when called from a view