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

Commit089b371

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 parent5bdf3cf commit089b371

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
@@ -1199,15 +1199,26 @@ ProcessWalSndrMessage(XLogRecPtr walEnd, TimestampTz sendTime)
11991199
{
12001200
char*sendtime;
12011201
char*receipttime;
1202+
intapplyDelay;
12021203

12031204
/* Copy because timestamptz_to_str returns a static buffer */
12041205
sendtime=pstrdup(timestamptz_to_str(sendTime));
12051206
receipttime=pstrdup(timestamptz_to_str(lastMsgReceiptTime));
1206-
elog(DEBUG2,"sendtime %s receipttime %s replication apply delay %d ms transfer latency %d ms",
1207-
sendtime,
1208-
receipttime,
1209-
GetReplicationApplyDelay(),
1210-
GetReplicationTransferLatency());
1207+
applyDelay=GetReplicationApplyDelay();
1208+
1209+
/* apply delay is not available */
1210+
if (applyDelay==-1)
1211+
elog(DEBUG2,"sendtime %s receipttime %s replication apply delay (N/A) transfer latency %d ms",
1212+
sendtime,
1213+
receipttime,
1214+
GetReplicationTransferLatency());
1215+
else
1216+
elog(DEBUG2,"sendtime %s receipttime %s replication apply delay %d ms transfer latency %d ms",
1217+
sendtime,
1218+
receipttime,
1219+
applyDelay,
1220+
GetReplicationTransferLatency());
1221+
12111222
pfree(sendtime);
12121223
pfree(receipttime);
12131224
}

‎src/backend/replication/walreceiverfuncs.c

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

309309
/*
310-
* Returns the replication apply delay in ms
310+
* Returns the replication apply delay in ms or -1
311+
* if the apply delay info is not available
311312
*/
312313
int
313314
GetReplicationApplyDelay(void)
@@ -321,6 +322,8 @@ GetReplicationApplyDelay(void)
321322
longsecs;
322323
intusecs;
323324

325+
TimestampTzchunckReplayStartTime;
326+
324327
SpinLockAcquire(&walrcv->mutex);
325328
receivePtr=walrcv->receivedUpto;
326329
SpinLockRelease(&walrcv->mutex);
@@ -330,7 +333,12 @@ GetReplicationApplyDelay(void)
330333
if (receivePtr==replayPtr)
331334
return0;
332335

333-
TimestampDifference(GetCurrentChunkReplayStartTime(),
336+
chunckReplayStartTime=GetCurrentChunkReplayStartTime();
337+
338+
if (chunckReplayStartTime==0)
339+
return-1;
340+
341+
TimestampDifference(chunckReplayStartTime,
334342
GetCurrentTimestamp(),
335343
&secs,&usecs);
336344

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp