@@ -475,9 +475,10 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
475
475
return ;
476
476
477
477
/*
478
- * If our initial RunningTransactionsData had an overflowed snapshot then we knew
479
- * we were missing some subxids from our snapshot. We can use this data as
480
- * an initial snapshot, but we cannot yet mark it valid. We know that the
478
+ * If our initial RunningTransactionsData had an overflowed snapshot then
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
481
482
* missing subxids are equal to or earlier than nextXid. After we
482
483
* initialise we continue to apply changes during recovery, so once the
483
484
* oldestRunningXid is later than the nextXid from the initial snapshot we
@@ -486,21 +487,31 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
486
487
*/
487
488
if (standbyState == STANDBY_SNAPSHOT_PENDING )
488
489
{
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 )
491
495
{
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 ;
497
497
}
498
498
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
+ }
504
515
}
505
516
506
517
Assert (standbyState == STANDBY_INITIALIZED );
@@ -606,7 +617,6 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
606
617
standbyState = STANDBY_SNAPSHOT_READY ;
607
618
608
619
standbySnapshotPendingXmin = InvalidTransactionId ;
609
- procArray -> lastOverflowedXid = InvalidTransactionId ;
610
620
}
611
621
612
622
/*
@@ -630,13 +640,15 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
630
640
631
641
LWLockRelease (ProcArrayLock );
632
642
633
- elog (trace_recovery (DEBUG2 ), "running transaction data initialized" );
634
643
KnownAssignedXidsDisplay (trace_recovery (DEBUG3 ));
635
644
if (standbyState == STANDBY_SNAPSHOT_READY )
636
- elog (trace_recovery (DEBUG2 ), "recovery snapshots are now enabled" );
645
+ elog (trace_recovery (DEBUG1 ), "recovery snapshots are now enabled" );
637
646
else
638
- ereport (LOG ,
639
- (errmsg ("consistent state delayed because recovery snapshot incomplete" )));
647
+ elog (trace_recovery (DEBUG1 ),
648
+ "recovery snapshot waiting for non-overflowed snapshot or "
649
+ "until oldest active xid on standby is at least %u (now %u)" ,
650
+ standbySnapshotPendingXmin ,
651
+ running -> oldestRunningXid );
640
652
}
641
653
642
654
/*
0 commit comments