Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit93b915b

Browse files
Start Hot Standby faster when initial snapshot is incomplete.
If the initial snapshot had overflowed then we can start wheneverthe latest snapshot is empty, not overflowed or as we did already,start when the xmin on primary was higher than xmax of our startingsnapshot, which proves we have full snapshot data.Bug report by Chris Redekop
1 parent9e5fe4d commit93b915b

File tree

1 file changed

+31
-19
lines changed

1 file changed

+31
-19
lines changed

‎src/backend/storage/ipc/procarray.c

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -476,8 +476,9 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
476476

477477
/*
478478
* If our initial RunningTransactionsData had an overflowed snapshot then
479-
* we knew we were missing some subxids from our snapshot. We can use this
480-
* data as an initial snapshot, but we cannot yet mark it valid. We know
479+
* we knew we were missing some subxids from our snapshot. If we continue
480+
* to see overflowed snapshots then we might never be able to start up,
481+
* so we make another test to see if our snapshot is now valid. We know
481482
* that the missing subxids are equal to or earlier than nextXid. After we
482483
* initialise we continue to apply changes during recovery, so once the
483484
* oldestRunningXid is later than the nextXid from the initial snapshot we
@@ -486,21 +487,31 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
486487
*/
487488
if (standbyState==STANDBY_SNAPSHOT_PENDING)
488489
{
489-
if (TransactionIdPrecedes(standbySnapshotPendingXmin,
490-
running->oldestRunningXid))
490+
/*
491+
* If the snapshot isn't overflowed or if its empty we can
492+
* reset our pending state and use this snapshot instead.
493+
*/
494+
if (!running->subxid_overflow||running->xcnt==0)
491495
{
492-
standbyState=STANDBY_SNAPSHOT_READY;
493-
elog(trace_recovery(DEBUG2),
494-
"running xact data now proven complete");
495-
elog(trace_recovery(DEBUG2),
496-
"recovery snapshots are now enabled");
496+
standbyState=STANDBY_INITIALIZED;
497497
}
498498
else
499-
elog(trace_recovery(DEBUG2),
500-
"recovery snapshot waiting for %u oldest active xid on standby is %u",
501-
standbySnapshotPendingXmin,
502-
running->oldestRunningXid);
503-
return;
499+
{
500+
if (TransactionIdPrecedes(standbySnapshotPendingXmin,
501+
running->oldestRunningXid))
502+
{
503+
standbyState=STANDBY_SNAPSHOT_READY;
504+
elog(trace_recovery(DEBUG1),
505+
"recovery snapshots are now enabled");
506+
}
507+
else
508+
elog(trace_recovery(DEBUG1),
509+
"recovery snapshot waiting for non-overflowed snapshot or "
510+
"until oldest active xid on standby is at least %u (now %u)",
511+
standbySnapshotPendingXmin,
512+
running->oldestRunningXid);
513+
return;
514+
}
504515
}
505516

506517
Assert(standbyState==STANDBY_INITIALIZED);
@@ -605,7 +616,6 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
605616
standbyState=STANDBY_SNAPSHOT_READY;
606617

607618
standbySnapshotPendingXmin=InvalidTransactionId;
608-
procArray->lastOverflowedXid=InvalidTransactionId;
609619
}
610620

611621
/*
@@ -628,13 +638,15 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
628638

629639
LWLockRelease(ProcArrayLock);
630640

631-
elog(trace_recovery(DEBUG2),"running transaction data initialized");
632641
KnownAssignedXidsDisplay(trace_recovery(DEBUG3));
633642
if (standbyState==STANDBY_SNAPSHOT_READY)
634-
elog(trace_recovery(DEBUG2),"recovery snapshots are now enabled");
643+
elog(trace_recovery(DEBUG1),"recovery snapshots are now enabled");
635644
else
636-
ereport(LOG,
637-
(errmsg("consistent state delayed because recovery snapshot incomplete")));
645+
elog(trace_recovery(DEBUG1),
646+
"recovery snapshot waiting for non-overflowed snapshot or "
647+
"until oldest active xid on standby is at least %u (now %u)",
648+
standbySnapshotPendingXmin,
649+
running->oldestRunningXid);
638650
}
639651

640652
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp