Skip to content

Commit bb8d738

Browse files
skyzhtristan957
authored andcommitted
Revert IsPrimaryAlive checks (#400)
* Revert "Add comment explaining why it is safe to use FirstNormalTransactionXid for oldestActiveXid while replica startup (#389)" This reverts commit 1eeab2d. * Revert "Set wasShutdown=true during hot-standby replica startup only when primary is not alive (#365)" This reverts commit b9336bc.
1 parent b111a6b commit bb8d738

File tree

1 file changed

+1
-49
lines changed
  • src/backend/access/transam

1 file changed

+1
-49
lines changed

src/backend/access/transam/xlog.c

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -542,18 +542,6 @@ typedef union WALInsertLockPadded
542542
char pad[PG_CACHE_LINE_SIZE];
543543
} WALInsertLockPadded;
544544

545-
546-
/*
547-
* NEON: check if primary node is running.
548-
* Correspondent GUC is received from control plane
549-
*/
550-
static bool
551-
IsPrimaryAlive()
552-
{
553-
const char* val = GetConfigOption("neon.primary_is_running", true, false);
554-
return val != NULL && strcmp(val, "on") == 0;
555-
}
556-
557545
/*
558546
* State of an exclusive backup, necessary to control concurrent activities
559547
* across sessions when working on exclusive backups.
@@ -7038,25 +7026,7 @@ StartupXLOG(void)
70387026
EndRecPtr = ControlFile->checkPointCopy.redo;
70397027

70407028
memcpy(&checkPoint, &ControlFile->checkPointCopy, sizeof(CheckPoint));
7041-
// When primary Neon compute node is started, we pretend that it started after a clean shutdown and
7042-
// no recovery is needed. We don't need to do WAL replay, the page server does that on a page-by-page basis.
7043-
// When a read-only replica is started, PostgreSQL normally waits for a shutdown checkpoint or running-xacts
7044-
// record before enabling hot standby, to establish which transactions are still running in the primary,
7045-
// and might still commit later. But if we know that the primary is not running - because the control plane
7046-
// says so - we can skip that. That avoids having to wait indefinitely if the primary is not running. This is
7047-
// particularly important for Neon because we don't start recovery from a checkpoint record, so there's
7048-
// no guarantee on when we'll see the next checkpoint or running-xacts record, if ever. so if we know the primary is
7049-
// not currently running, also set wasShutdown to 'true'.
7050-
if (StandbyModeRequested &&
7051-
PrimaryConnInfo != NULL && *PrimaryConnInfo != '\0')
7052-
{
7053-
if (!IsPrimaryAlive())
7054-
wasShutdown = true;
7055-
else
7056-
wasShutdown = false;
7057-
}
7058-
else
7059-
wasShutdown = true;
7029+
wasShutdown = true;
70607030

70617031
/* Initialize expectedTLEs, like ReadRecord() does */
70627032
expectedTLEs = readTimeLineHistory(checkPoint.ThisTimeLineID);
@@ -7226,24 +7196,6 @@ StartupXLOG(void)
72267196
ereport(PANIC,
72277197
(errmsg("invalid next transaction ID")));
72287198

7229-
if (ZenithRecoveryRequested)
7230-
{
7231-
if (wasShutdown)
7232-
checkPoint.oldestActiveXid = InvalidTransactionId;
7233-
else if (!TransactionIdIsValid(checkPoint.oldestActiveXid))
7234-
{
7235-
/*
7236-
* Pageserver extracts oldestActiveXid from snapshot and running xacts WAL records
7237-
* and include it in checkpoint sent in basebackup.
7238-
* So oldestActiveXid can be zero only after database initialization when no checkpoints are yet performed
7239-
* and not running xacts records was logged.
7240-
* In this case it is possible to use FirstNormalTransactionId as safe conservative estimation
7241-
* of oldest active transaction XID.
7242-
*/
7243-
checkPoint.oldestActiveXid = FirstNormalTransactionId;
7244-
}
7245-
}
7246-
72477199
/* initialize shared memory variables from the checkpoint record */
72487200
ShmemVariableCache->nextXid = checkPoint.nextXid;
72497201
ShmemVariableCache->nextOid = checkPoint.nextOid;

0 commit comments

Comments
 (0)