Re: PG13 fails to startup even though the current transaction is equal to the target transaction

From: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
To: Sean Jezewski <sjezewski(at)salesforce(dot)com>, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: PG13 fails to startup even though the current transaction is equal to the target transaction
Date: 2021-03-22 14:37:48
Message-ID: 86e9abcd-a902-de62-344e-5c4336b61b58@oss.nttdata.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2021/03/22 21:40, Sean Jezewski wrote:
> Hi Kyotaro -
>
> Thanks for the response.
>
> I think it boils down to your comment:
>
> > I'm not sure.  The direct cause of the "issue" is a promotion trigger
> > that came before reaching recovery target.  That won't happen if the
> > "someone" doesn't do that.
>
> I think the question is 'under what conditions is it safe to do the promotion' ?
>
> What is your recommendation in this case? The end of the archive has been reached. All transactions have been replayed. And in fact the current transaction id is exactly equal to the target recovery transaction id.

I guess that the transaction with this current XID has not been committed
yet at that moment. Right? I thought that because you confirmed the XID
by SELECT pg_catalog.txid_snapshot_xmax(pg_catalog.txid_current_snapshot()).
IIUC this query doesn't return the XID of already-committed transaction.

The standby thinks that the recovery reaches the recovery target when
the XID of *committed* transaction get equal to the recovery_target_xid.
So in your case, the standby didn't reached the recovery target when you
requested the promotion. IMO this is why you got that FATAL error.

Regards,

--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2021-03-22 14:41:33 Re: [HACKERS] Custom compression methods
Previous Message Fabrízio de Royes Mello 2021-03-22 14:10:53 Re: Minimal logical decoding on standbys