Re: BUG #17744: Fail Assert while recoverying from pg_basebackup

From: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
To: zxwsbg12138(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #17744: Fail Assert while recoverying from pg_basebackup
Date: 2023-01-13 09:36:05
Message-ID: 20230113.183605.282317833423860381.horikyota.ntt@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

At Tue, 10 Jan 2023 07:45:45 +0000, PG Bug reporting form <noreply(at)postgresql(dot)org> wrote in
> #2 0x0000000000b378e9 in ExceptionalCondition (
> conditionName=0xd13697 "TransactionIdIsValid(initial)",
> errorType=0xd12df4 "FailedAssertion", fileName=0xd12de8 "procarray.c",
>
> lineNumber=1750) at assert.c:69
> #3 0x0000000000962195 in ComputeXidHorizons (h=0x7ffe93de25e0)
> at procarray.c:1750
> #4 0x00000000009628a3 in GetOldestTransactionIdConsideredRunning ()
> at procarray.c:2050
> #5 0x00000000005972bf in CreateRestartPoint (flags=256) at xlog.c:7153
> #6 0x00000000008cae37 in CheckpointerMain () at checkpointer.c:464

The function requires a valid value in
ShmemVariableCache->latestCompleteXid. But it is not initialized and
maintained in this case. The attached quick hack seems working, but
of course more decent fix is needed.

diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 0070d56b0b..667c990301 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -5363,7 +5363,7 @@ StartupXLOG(void)
* control file and we've established a recovery snapshot from a
* running-xacts WAL record.
*/
- if (ArchiveRecoveryRequested && EnableHotStandby)
+ if (1 || (ArchiveRecoveryRequested && EnableHotStandby))
{
TransactionId *xids;
int nxids;
diff --git a/src/backend/storage/ipc/standby.c b/src/backend/storage/ipc/standby.c
index 94cc860f5f..c814c991f8 100644
--- a/src/backend/storage/ipc/standby.c
+++ b/src/backend/storage/ipc/standby.c
@@ -1161,7 +1161,7 @@ standby_redo(XLogReaderState *record)
Assert(!XLogRecHasAnyBlockRefs(record));

/* Do nothing if we're not in hot standby mode */
- if (standbyState == STANDBY_DISABLED)
+ if (standbyState == STANDBY_DISABLED && info != XLOG_RUNNING_XACTS)
return;

if (info == XLOG_STANDBY_LOCK)

regards.

--
Kyotaro Horiguchi
NTT Open Source Software Center

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Mats Kindahl 2023-01-13 10:05:01 Re: Crash during backend start when low on memory
Previous Message John Naylor 2023-01-13 01:59:22 Re: Facing issue while installing postgresql