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

Commit8068676

Browse files
Avoid overflow in MaybeRemoveOldWalSummaries().
This commit limits the maximum value of wal_summary_keep_time toINT_MAX / SECS_PER_MINUTE to avoid overflow when it is converted toseconds. In passing, use the HOURS_PER_DAY, MINS_PER_HOUR, andSECS_PER_MINUTE macros in the code for this GUC instead of hard-coding those values.Discussion:https://postgr.es/m/20240314210010.GA3056455%40nathanxps13
1 parent9acae56 commit8068676

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

‎src/backend/postmaster/walsummarizer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ static XLogRecPtr redo_pointer_at_last_summary_removal = InvalidXLogRecPtr;
140140
* GUC parameters
141141
*/
142142
boolsummarize_wal= false;
143-
intwal_summary_keep_time=10*24*60;
143+
intwal_summary_keep_time=10*HOURS_PER_DAY*MINS_PER_HOUR;
144144

145145
staticvoidWalSummarizerShutdown(intcode,Datumarg);
146146
staticXLogRecPtrGetLatestLSN(TimeLineID*tli);
@@ -1480,7 +1480,7 @@ MaybeRemoveOldWalSummaries(void)
14801480
* Files should only be removed if the last modification time precedes the
14811481
* cutoff time we compute here.
14821482
*/
1483-
cutoff_time=time(NULL)-60*wal_summary_keep_time;
1483+
cutoff_time=time(NULL)-wal_summary_keep_time*SECS_PER_MINUTE;
14841484

14851485
/* Get all the summaries that currently exist. */
14861486
wslist=GetWalSummaries(0,InvalidXLogRecPtr,InvalidXLogRecPtr);

‎src/backend/utils/misc/guc_tables.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3293,9 +3293,9 @@ struct config_int ConfigureNamesInt[] =
32933293
GUC_UNIT_MIN,
32943294
},
32953295
&wal_summary_keep_time,
3296-
10*24*60,/* 10 days */
3296+
10*HOURS_PER_DAY*MINS_PER_HOUR,/* 10 days */
32973297
0,
3298-
INT_MAX,
3298+
INT_MAX /SECS_PER_MINUTE,
32993299
NULL,NULL,NULL
33003300
},
33013301

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp