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

Commit364c006

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 parent82fe8b1 commit364c006

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
@@ -1191,15 +1191,26 @@ ProcessWalSndrMessage(XLogRecPtr walEnd, TimestampTz sendTime)
11911191
{
11921192
char*sendtime;
11931193
char*receipttime;
1194+
intapplyDelay;
11941195

11951196
/* Copy because timestamptz_to_str returns a static buffer */
11961197
sendtime=pstrdup(timestamptz_to_str(sendTime));
11971198
receipttime=pstrdup(timestamptz_to_str(lastMsgReceiptTime));
1198-
elog(DEBUG2,"sendtime %s receipttime %s replication apply delay %d ms transfer latency %d ms",
1199-
sendtime,
1200-
receipttime,
1201-
GetReplicationApplyDelay(),
1202-
GetReplicationTransferLatency());
1199+
applyDelay=GetReplicationApplyDelay();
1200+
1201+
/* apply delay is not available */
1202+
if (applyDelay==-1)
1203+
elog(DEBUG2,"sendtime %s receipttime %s replication apply delay (N/A) transfer latency %d ms",
1204+
sendtime,
1205+
receipttime,
1206+
GetReplicationTransferLatency());
1207+
else
1208+
elog(DEBUG2,"sendtime %s receipttime %s replication apply delay %d ms transfer latency %d ms",
1209+
sendtime,
1210+
receipttime,
1211+
applyDelay,
1212+
GetReplicationTransferLatency());
1213+
12031214
pfree(sendtime);
12041215
pfree(receipttime);
12051216
}

‎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