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

Appearance settings

Commit 8068676

Browse filesBrowse files
Avoid overflow in MaybeRemoveOldWalSummaries().
This commit limits the maximum value of wal_summary_keep_time to INT_MAX / SECS_PER_MINUTE to avoid overflow when it is converted to seconds. In passing, use the HOURS_PER_DAY, MINS_PER_HOUR, and SECS_PER_MINUTE macros in the code for this GUC instead of hard- coding those values. Discussion: https://postgr.es/m/20240314210010.GA3056455%40nathanxps13
1 parent 9acae56 commit 8068676
Copy full SHA for 8068676

File tree

Expand file treeCollapse file tree

2 files changed

+4
-4
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+4
-4
lines changed

‎src/backend/postmaster/walsummarizer.c

Copy file name to clipboardExpand all lines: src/backend/postmaster/walsummarizer.c
+2-2Lines 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
bool summarize_wal = false;
143-
int wal_summary_keep_time = 10 * 24 * 60;
143+
int wal_summary_keep_time = 10 * HOURS_PER_DAY * MINS_PER_HOUR;
144144

145145
static void WalSummarizerShutdown(int code, Datum arg);
146146
static XLogRecPtr GetLatestLSN(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

Copy file name to clipboardExpand all lines: src/backend/utils/misc/guc_tables.c
+2-2Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.