Skip to content

Commit 3946b2e

Browse files
authored
Revert IsPrimaryAlive checks (#402)
* Revert "Add comment explaining why it is safe to use FirstNormalTransactionXid for oldestActiveXid while replica startup (#387)" This reverts commit 67240b5. * Revert "Set wasShutdown=true during hot-standby replica startup only when primary is not alive (#363)" This reverts commit 61c280c.
1 parent 111e82c commit 3946b2e

File tree

2 files changed

+1
-50
lines changed

2 files changed

+1
-50
lines changed

src/backend/access/transam/xlog.c

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5330,24 +5330,6 @@ StartupXLOG(void)
53305330
&haveBackupLabel, &haveTblspcMap);
53315331
checkPoint = ControlFile->checkPointCopy;
53325332

5333-
if (ZenithRecoveryRequested)
5334-
{
5335-
if (wasShutdown)
5336-
checkPoint.oldestActiveXid = InvalidTransactionId;
5337-
else if (!TransactionIdIsValid(checkPoint.oldestActiveXid))
5338-
{
5339-
/*
5340-
* Pageserver extracts oldestActiveXid from snapshot and running xacts WAL records
5341-
* and include it in checkpoint sent in basebackup.
5342-
* So oldestActiveXid can be zero only after database initialization when no checkpoints are yet performed
5343-
* and not running xacts records was logged.
5344-
* In this case it is possible to use FirstNormalTransactionId as safe conservative estimation
5345-
* of oldest active transaction XID.
5346-
*/
5347-
checkPoint.oldestActiveXid = FirstNormalTransactionId;
5348-
}
5349-
}
5350-
53515333
/* initialize shared memory variables from the checkpoint record */
53525334
ShmemVariableCache->nextXid = checkPoint.nextXid;
53535335
ShmemVariableCache->nextOid = checkPoint.nextOid;

src/backend/access/transam/xlogrecovery.c

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -548,18 +548,6 @@ XLogWaitForReplayOf(XLogRecPtr redoEndRecPtr)
548548
ConditionVariableCancelSleep();
549549
}
550550

551-
552-
/*
553-
* NEON: check if primary node is running.
554-
* Correspondent GUC is received from control plane
555-
*/
556-
static bool
557-
IsPrimaryAlive()
558-
{
559-
const char* val = GetConfigOption("neon.primary_is_running", true, false);
560-
return val != NULL && strcmp(val, "on") == 0;
561-
}
562-
563551
/*
564552
* Prepare the system for WAL recovery, if needed.
565553
*
@@ -816,26 +804,7 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr,
816804
//EndRecPtr = ControlFile->checkPointCopy.redo;
817805

818806
memcpy(&checkPoint, &ControlFile->checkPointCopy, sizeof(CheckPoint));
819-
// When primary Neon compute node is started, we pretend that it started after a clean shutdown and
820-
// no recovery is needed. We don't need to do WAL replay, the page server does that on a page-by-page basis.
821-
// When a read-only replica is started, PostgreSQL normally waits for a shutdown checkpoint or running-xacts
822-
// record before enabling hot standby, to establish which transactions are still running in the primary,
823-
// and might still commit later. But if we know that the primary is not running - because the control plane
824-
// says so - we can skip that. That avoids having to wait indefinitely if the primary is not running. This is
825-
// particularly important for Neon because we don't start recovery from a checkpoint record, so there's
826-
// no guarantee on when we'll see the next checkpoint or running-xacts record, if ever. so if we know the primary is
827-
// not currently running, also set wasShutdown to 'true'.
828-
if (StandbyModeRequested &&
829-
PrimaryConnInfo != NULL && *PrimaryConnInfo != '\0')
830-
{
831-
if (!IsPrimaryAlive())
832-
wasShutdown = true;
833-
else
834-
wasShutdown = false;
835-
}
836-
else
837-
wasShutdown = true;
838-
807+
wasShutdown = true;
839808

840809
/* Initialize expectedTLEs, like ReadRecord() does */
841810
expectedTLEs = readTimeLineHistory(checkPoint.ThisTimeLineID);

0 commit comments

Comments
 (0)