@@ -476,8 +476,9 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
476
476
477
477
/*
478
478
* 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
481
482
* that the 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 );
@@ -605,7 +616,6 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
605
616
standbyState = STANDBY_SNAPSHOT_READY ;
606
617
607
618
standbySnapshotPendingXmin = InvalidTransactionId ;
608
- procArray -> lastOverflowedXid = InvalidTransactionId ;
609
619
}
610
620
611
621
/*
@@ -628,13 +638,15 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
628
638
629
639
LWLockRelease (ProcArrayLock );
630
640
631
- elog (trace_recovery (DEBUG2 ),"running transaction data initialized" );
632
641
KnownAssignedXidsDisplay (trace_recovery (DEBUG3 ));
633
642
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" );
635
644
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 );
638
650
}
639
651
640
652
/*