I wonder if there is corner case below where there are no WAL records to
replay during standby recovery. Specifically, that may cause
IsRunningXactDataValid() to return false since latestObservedXid remains set
to InvalidTransactionId and that prevents postmaster from serving read-only
clients.

I don't have a test case, but I recall seeing the issue while experimenting.
Though that could be because of the WALInsertLock issue reported earlier.

           /*
                 * Can we signal Postmaster to enter consistent recovery
mode?
                 *
                 * There are two points in the log that we must pass. The
first
                 * is minRecoveryPoint, which is the LSN at the time the
                 * base backup was taken that we are about to rollfoward
from.
                 * If recovery has ever crashed or was stopped there is also
                 * another point also: minSafeStartPoint, which we know the
                 * latest LSN that recovery could have reached prior to
crash.
                 *
                 * We must also have assembled sufficient information about
                 * transaction state to allow valid snapshots to be taken.
                 */
                if (!reachedSafeStartPoint &&
                     IsRunningXactDataValid() &&
                     XLByteLE(ControlFile->minSafeStartPoint, EndRecPtr) &&
                     XLByteLE(ControlFile->minRecoveryPoint, EndRecPtr))
                {
                    reachedSafeStartPoint = true;
                    if (InArchiveRecovery)
                    {
                        ereport(LOG,
                            (errmsg("database has now reached consistent
state at %X/%X",
                                EndRecPtr.xlogid, EndRecPtr.xrecoff)));
                        InitRecoveryTransactionEnvironment();
                        StartCleanupDelayStats();
                        if (IsUnderPostmaster)
                            SendPostmasterSignal(PMSIGNAL_RECOVERY_START);
                    }
                }


Thanks,
Pavan

-- 
Pavan Deolasee
EnterpriseDB     http://www.enterprisedb.com

Reply via email to