Skip to content

Commit 6a2cbe1

Browse files
Ensure all replication message info is available and correct via WalRcv
1 parent 6f4b8a4 commit 6a2cbe1

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

src/backend/replication/walreceiver.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ WalReceiverMain(void)
219219
startpoint = walrcv->receiveStart;
220220

221221
/* Initialise to a sanish value */
222-
walrcv->lastMsgSendTime = walrcv->lastMsgReceiptTime = GetCurrentTimestamp();
222+
walrcv->lastMsgSendTime = walrcv->lastMsgReceiptTime = walrcv->latestWalEndTime = GetCurrentTimestamp();
223223

224224
SpinLockRelease(&walrcv->mutex);
225225

@@ -759,6 +759,9 @@ ProcessWalSndrMessage(XLogRecPtr walEnd, TimestampTz sendTime)
759759

760760
/* Update shared-memory status */
761761
SpinLockAcquire(&walrcv->mutex);
762+
if (XLByteLT(walrcv->latestWalEnd, walEnd))
763+
walrcv->latestWalEndTime = sendTime;
764+
walrcv->latestWalEnd = walEnd;
762765
walrcv->lastMsgSendTime = sendTime;
763766
walrcv->lastMsgReceiptTime = lastMsgReceiptTime;
764767
SpinLockRelease(&walrcv->mutex);

src/backend/replication/walreceiverfuncs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ GetReplicationApplyDelay(void)
261261

262262
replayPtr = GetXLogReplayRecPtr(NULL);
263263

264-
if (XLByteLE(receivePtr, replayPtr))
264+
if (XLByteEQ(receivePtr, replayPtr))
265265
return 0;
266266

267267
TimestampDifference(GetCurrentChunkReplayStartTime(),

src/include/replication/walreceiver.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ typedef struct
8383
TimestampTz lastMsgSendTime;
8484
TimestampTz lastMsgReceiptTime;
8585

86+
/*
87+
* Latest reported end of WAL on the sender
88+
*/
89+
XLogRecPtr latestWalEnd;
90+
TimestampTz latestWalEndTime;
91+
8692
/*
8793
* connection string; is used for walreceiver to connect with the primary.
8894
*/

0 commit comments

Comments
 (0)