Skip to content

Commit e8ac25f

Browse files
skyzhtristan957
authored andcommitted
Revert IsPrimaryAlive checks (#401)
* Revert "Add comment explaining why it is safe to use FirstNormalTransactionXid for oldestActiveXid while replica startup (#388)" This reverts commit 79b6351. * Revert "Set wasShutdown=true during hot-standby replica startup only when primary is not alive (#364)" This reverts commit be91d91.
1 parent 0db2c4a commit e8ac25f

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
@@ -5182,24 +5182,6 @@ StartupXLOG(void)
51825182
&haveBackupLabel, &haveTblspcMap);
51835183
checkPoint = ControlFile->checkPointCopy;
51845184

5185-
if (ZenithRecoveryRequested)
5186-
{
5187-
if (wasShutdown)
5188-
checkPoint.oldestActiveXid = InvalidTransactionId;
5189-
else if (!TransactionIdIsValid(checkPoint.oldestActiveXid))
5190-
{
5191-
/*
5192-
* Pageserver extracts oldestActiveXid from snapshot and running xacts WAL records
5193-
* and include it in checkpoint sent in basebackup.
5194-
* So oldestActiveXid can be zero only after database initialization when no checkpoints are yet performed
5195-
* and not running xacts records was logged.
5196-
* In this case it is possible to use FirstNormalTransactionId as safe conservative estimation
5197-
* of oldest active transaction XID.
5198-
*/
5199-
checkPoint.oldestActiveXid = FirstNormalTransactionId;
5200-
}
5201-
}
5202-
52035185
/* initialize shared memory variables from the checkpoint record */
52045186
ShmemVariableCache->nextXid = checkPoint.nextXid;
52055187
ShmemVariableCache->nextOid = checkPoint.nextOid;

src/backend/access/transam/xlogrecovery.c

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

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

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

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

0 commit comments

Comments
 (0)