Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4909cb5

Browse files
committed
Fix integer overflow in debug message of walreceiver
The message tries to tell the replication apply delay which fails ifthe first WAL record is not applied yet. Fix is, instead of tellingoverflowed minus numeric, showing "N/A" which indicates that the delaydata is not yet available. Problem reported by me and patch byFabrízio de Royes Mello.Back patched to 9.4, 9.3 and 9.2 stable branches (9.1 and 9.0 do nothave the debug message).
1 parent590fc5d commit4909cb5

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

‎src/backend/replication/walreceiver.c

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -793,15 +793,26 @@ ProcessWalSndrMessage(XLogRecPtr walEnd, TimestampTz sendTime)
793793
{
794794
char*sendtime;
795795
char*receipttime;
796+
intapplyDelay;
796797

797798
/* Copy because timestamptz_to_str returns a static buffer */
798799
sendtime=pstrdup(timestamptz_to_str(sendTime));
799800
receipttime=pstrdup(timestamptz_to_str(lastMsgReceiptTime));
800-
elog(DEBUG2,"sendtime %s receipttime %s replication apply delay %d ms transfer latency %d ms",
801-
sendtime,
802-
receipttime,
803-
GetReplicationApplyDelay(),
804-
GetReplicationTransferLatency());
801+
applyDelay=GetReplicationApplyDelay();
802+
803+
/* apply delay is not available */
804+
if (applyDelay==-1)
805+
elog(DEBUG2,"sendtime %s receipttime %s replication apply delay (N/A) transfer latency %d ms",
806+
sendtime,
807+
receipttime,
808+
GetReplicationTransferLatency());
809+
else
810+
elog(DEBUG2,"sendtime %s receipttime %s replication apply delay %d ms transfer latency %d ms",
811+
sendtime,
812+
receipttime,
813+
applyDelay,
814+
GetReplicationTransferLatency());
815+
805816
pfree(sendtime);
806817
pfree(receipttime);
807818
}

‎src/backend/replication/walreceiverfuncs.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,8 @@ GetWalRcvWriteRecPtr(XLogRecPtr *latestChunkStart)
241241
}
242242

243243
/*
244-
* Returns the replication apply delay in ms
244+
* Returns the replication apply delay in ms or -1
245+
* if the apply delay info is not available
245246
*/
246247
int
247248
GetReplicationApplyDelay(void)
@@ -255,6 +256,8 @@ GetReplicationApplyDelay(void)
255256
longsecs;
256257
intusecs;
257258

259+
TimestampTzchunckReplayStartTime;
260+
258261
SpinLockAcquire(&walrcv->mutex);
259262
receivePtr=walrcv->receivedUpto;
260263
SpinLockRelease(&walrcv->mutex);
@@ -264,7 +267,12 @@ GetReplicationApplyDelay(void)
264267
if (XLByteEQ(receivePtr,replayPtr))
265268
return0;
266269

267-
TimestampDifference(GetCurrentChunkReplayStartTime(),
270+
chunckReplayStartTime=GetCurrentChunkReplayStartTime();
271+
272+
if (chunckReplayStartTime==0)
273+
return-1;
274+
275+
TimestampDifference(chunckReplayStartTime,
268276
GetCurrentTimestamp(),
269277
&secs,&usecs);
270278

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp