Skip to content

Commit 87d8bd7

Browse files
Ensure all replication message info is available and correct via WalRcv
1 parent be690e2 commit 87d8bd7

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
@@ -218,7 +218,7 @@ WalReceiverMain(void)
218218
startpoint = walrcv->receiveStart;
219219

220220
/* Initialise to a sanish value */
221-
walrcv->lastMsgSendTime = walrcv->lastMsgReceiptTime = GetCurrentTimestamp();
221+
walrcv->lastMsgSendTime = walrcv->lastMsgReceiptTime = walrcv->latestWalEndTime = GetCurrentTimestamp();
222222

223223
SpinLockRelease(&walrcv->mutex);
224224

@@ -749,6 +749,9 @@ ProcessWalSndrMessage(XLogRecPtr walEnd, TimestampTz sendTime)
749749

750750
/* Update shared-memory status */
751751
SpinLockAcquire(&walrcv->mutex);
752+
if (XLByteLT(walrcv->latestWalEnd, walEnd))
753+
walrcv->latestWalEndTime = sendTime;
754+
walrcv->latestWalEnd = walEnd;
752755
walrcv->lastMsgSendTime = sendTime;
753756
walrcv->lastMsgReceiptTime = lastMsgReceiptTime;
754757
SpinLockRelease(&walrcv->mutex);

src/backend/replication/walreceiverfuncs.c

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

261261
replayPtr = GetXLogReplayRecPtr(NULL);
262262

263-
if (XLByteLE(receivePtr, replayPtr))
263+
if (XLByteEQ(receivePtr, replayPtr))
264264
return 0;
265265

266266
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy