]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Ensure all replication message info is available and correct via WalRcv
authorSimon Riggs <simon@2ndQuadrant.com>
Thu, 9 Aug 2012 16:03:10 +0000 (17:03 +0100)
committerSimon Riggs <simon@2ndQuadrant.com>
Thu, 9 Aug 2012 16:03:10 +0000 (17:03 +0100)
src/backend/replication/walreceiver.c
src/backend/replication/walreceiverfuncs.c
src/include/replication/walreceiver.h

index c8b04d69691792277571cca493da7f7a0614bfaa..7a0102d694bbb3104581768d82fd6c353c22fa5e 100644 (file)
@@ -219,7 +219,7 @@ WalReceiverMain(void)
        startpoint = walrcv->receiveStart;
 
        /* Initialise to a sanish value */
-       walrcv->lastMsgSendTime = walrcv->lastMsgReceiptTime = GetCurrentTimestamp();
+       walrcv->lastMsgSendTime = walrcv->lastMsgReceiptTime = walrcv->latestWalEndTime = GetCurrentTimestamp();
 
        SpinLockRelease(&walrcv->mutex);
 
@@ -759,6 +759,9 @@ ProcessWalSndrMessage(XLogRecPtr walEnd, TimestampTz sendTime)
 
        /* Update shared-memory status */
        SpinLockAcquire(&walrcv->mutex);
+       if (XLByteLT(walrcv->latestWalEnd, walEnd))
+               walrcv->latestWalEndTime = sendTime;
+       walrcv->latestWalEnd = walEnd;
        walrcv->lastMsgSendTime = sendTime;
        walrcv->lastMsgReceiptTime = lastMsgReceiptTime;
        SpinLockRelease(&walrcv->mutex);
index 876196f9da397fe578a5b1819f6d34ff9d563b3f..4dfb86a863211d325282ce89bfcd5a84e2b39ac7 100644 (file)
@@ -261,7 +261,7 @@ GetReplicationApplyDelay(void)
 
        replayPtr = GetXLogReplayRecPtr(NULL);
 
-       if (XLByteLE(receivePtr, replayPtr))
+       if (XLByteEQ(receivePtr, replayPtr))
                return 0;
 
        TimestampDifference(GetCurrentChunkReplayStartTime(),
index 8c402deb96f4a103f571732af00c0a5bc0663b81..9eb96c8820e60e38063dbe253938ab6060bcbc25 100644 (file)
@@ -83,6 +83,12 @@ typedef struct
        TimestampTz lastMsgSendTime;
        TimestampTz lastMsgReceiptTime;
 
+       /*
+        * Latest reported end of WAL on the sender
+        */
+       XLogRecPtr      latestWalEnd;
+       TimestampTz latestWalEndTime;
+
        /*
         * connection string; is used for walreceiver to connect with the primary.
         */