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

Commit4324785

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 parent32269be commit4324785

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
@@ -1202,15 +1202,26 @@ ProcessWalSndrMessage(XLogRecPtr walEnd, TimestampTz sendTime)
12021202
{
12031203
char*sendtime;
12041204
char*receipttime;
1205+
intapplyDelay;
12051206

12061207
/* Copy because timestamptz_to_str returns a static buffer */
12071208
sendtime=pstrdup(timestamptz_to_str(sendTime));
12081209
receipttime=pstrdup(timestamptz_to_str(lastMsgReceiptTime));
1209-
elog(DEBUG2,"sendtime %s receipttime %s replication apply delay %d ms transfer latency %d ms",
1210-
sendtime,
1211-
receipttime,
1212-
GetReplicationApplyDelay(),
1213-
GetReplicationTransferLatency());
1210+
applyDelay=GetReplicationApplyDelay();
1211+
1212+
/* apply delay is not available */
1213+
if (applyDelay==-1)
1214+
elog(DEBUG2,"sendtime %s receipttime %s replication apply delay (N/A) transfer latency %d ms",
1215+
sendtime,
1216+
receipttime,
1217+
GetReplicationTransferLatency());
1218+
else
1219+
elog(DEBUG2,"sendtime %s receipttime %s replication apply delay %d ms transfer latency %d ms",
1220+
sendtime,
1221+
receipttime,
1222+
applyDelay,
1223+
GetReplicationTransferLatency());
1224+
12141225
pfree(sendtime);
12151226
pfree(receipttime);
12161227
}

‎src/backend/replication/walreceiverfuncs.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,8 @@ GetWalRcvWriteRecPtr(XLogRecPtr *latestChunkStart, TimeLineID *receiveTLI)
314314
}
315315

316316
/*
317-
* Returns the replication apply delay in ms
317+
* Returns the replication apply delay in ms or -1
318+
* if the apply delay info is not available
318319
*/
319320
int
320321
GetReplicationApplyDelay(void)
@@ -328,6 +329,8 @@ GetReplicationApplyDelay(void)
328329
longsecs;
329330
intusecs;
330331

332+
TimestampTzchunckReplayStartTime;
333+
331334
SpinLockAcquire(&walrcv->mutex);
332335
receivePtr=walrcv->receivedUpto;
333336
SpinLockRelease(&walrcv->mutex);
@@ -337,7 +340,12 @@ GetReplicationApplyDelay(void)
337340
if (receivePtr==replayPtr)
338341
return0;
339342

340-
TimestampDifference(GetCurrentChunkReplayStartTime(),
343+
chunckReplayStartTime=GetCurrentChunkReplayStartTime();
344+
345+
if (chunckReplayStartTime==0)
346+
return-1;
347+
348+
TimestampDifference(chunckReplayStartTime,
341349
GetCurrentTimestamp(),
342350
&secs,&usecs);
343351

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp