summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Riggs2012-08-09 16:03:10 +0000
committerSimon Riggs2012-08-09 16:03:10 +0000
commit6a2cbe12358d3e3c356d863c8fc40c5f8daadb2a (patch)
treec73114b5d5a5f0d43b84b9019536f6b23ba5aa01
parent6f4b8a4f4f7a2d683ff79ab59d3693714b965e3d (diff)
Ensure all replication message info is available and correct via WalRcv
-rw-r--r--src/backend/replication/walreceiver.c5
-rw-r--r--src/backend/replication/walreceiverfuncs.c2
-rw-r--r--src/include/replication/walreceiver.h6
3 files changed, 11 insertions, 2 deletions
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index c8b04d69691..7a0102d694b 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -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);
diff --git a/src/backend/replication/walreceiverfuncs.c b/src/backend/replication/walreceiverfuncs.c
index 876196f9da3..4dfb86a8632 100644
--- a/src/backend/replication/walreceiverfuncs.c
+++ b/src/backend/replication/walreceiverfuncs.c
@@ -261,7 +261,7 @@ GetReplicationApplyDelay(void)
replayPtr = GetXLogReplayRecPtr(NULL);
- if (XLByteLE(receivePtr, replayPtr))
+ if (XLByteEQ(receivePtr, replayPtr))
return 0;
TimestampDifference(GetCurrentChunkReplayStartTime(),
diff --git a/src/include/replication/walreceiver.h b/src/include/replication/walreceiver.h
index 8c402deb96f..9eb96c8820e 100644
--- a/src/include/replication/walreceiver.h
+++ b/src/include/replication/walreceiver.h
@@ -84,6 +84,12 @@ typedef struct
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.
*/
char conninfo[MAXCONNINFO];