diff options
| author | Nathan Bossart | 2024-03-20 18:31:58 +0000 |
|---|---|---|
| committer | Nathan Bossart | 2024-03-20 18:31:58 +0000 |
| commit | 80686761c49d5194d224b344e968c26981611726 (patch) | |
| tree | 7ff7640bcf58bae4213cfe38e746035c7c89b82f /src/backend/postmaster | |
| parent | 9acae56ce0b0812f3e940cf1f87e73e8d5784e78 (diff) | |
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
Diffstat (limited to 'src/backend/postmaster')
| -rw-r--r-- | src/backend/postmaster/walsummarizer.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/backend/postmaster/walsummarizer.c b/src/backend/postmaster/walsummarizer.c index b412d0eb866..0cd5080fa78 100644 --- a/src/backend/postmaster/walsummarizer.c +++ b/src/backend/postmaster/walsummarizer.c @@ -140,7 +140,7 @@ static XLogRecPtr redo_pointer_at_last_summary_removal = InvalidXLogRecPtr; * GUC parameters */ bool summarize_wal = false; -int wal_summary_keep_time = 10 * 24 * 60; +int wal_summary_keep_time = 10 * HOURS_PER_DAY * MINS_PER_HOUR; static void WalSummarizerShutdown(int code, Datum arg); static XLogRecPtr GetLatestLSN(TimeLineID *tli); @@ -1480,7 +1480,7 @@ MaybeRemoveOldWalSummaries(void) * Files should only be removed if the last modification time precedes the * cutoff time we compute here. */ - cutoff_time = time(NULL) - 60 * wal_summary_keep_time; + cutoff_time = time(NULL) - wal_summary_keep_time * SECS_PER_MINUTE; /* Get all the summaries that currently exist. */ wslist = GetWalSummaries(0, InvalidXLogRecPtr, InvalidXLogRecPtr); |
