| From: | Cliff Clark <Cliff_Clark(at)selinc(dot)com> |
|---|---|
| To: | Michael Paquier <michael(at)paquier(dot)xyz> |
| Cc: | "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: [PATCH] Auto vacuum should still run when clock is set back |
| Date: | 2026-03-25 16:24:13 |
| Message-ID: | SA1PR22MB54663B5DE664DA1B68B053CEE549A@SA1PR22MB5466.namprd22.prod.outlook.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Let me try this again:
From a7f04a8b5202eb794ed6846bb8fddccdeecd643c Mon Sep 17 00:00:00 2001
From: Cliff Clark <Cliff_Clark(at)selinc(dot)com>
Date: Tue, 24 Mar 2026 11:32:43 -0700
Subject: [PATCH] Autovacuum should still run when clock is set back
Add code to detect when the clock was set back since the last autovacuum
launcher run. When this happens, rebuild the database list so that
autovacuum will continue to run.
---
src/backend/postmaster/autovacuum.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c
index 219673db930..9f2c6434802 100644
--- a/src/backend/postmaster/autovacuum.c
+++ b/src/backend/postmaster/autovacuum.c
@@ -377,6 +377,7 @@ void
AutoVacLauncherMain(const void *startup_data, size_t startup_data_len)
{
sigjmp_buf local_sigjmp_buf;
+ TimestampTz last_current_time;
Assert(startup_data_len == 0);
@@ -568,6 +569,12 @@ AutoVacLauncherMain(const void *startup_data, size_t startup_data_len)
AutoVacuumShmem->av_launcherpid = MyProcPid;
+ /*
+ * Set the initial last run time to just before we build the worker
+ * schedule.
+ */
+ last_current_time = GetCurrentTimestamp();
+
/*
* Create the initial database list. The invariant we want this list to
* keep is that it's ordered by decreasing next_worker. As soon as an
@@ -649,6 +656,16 @@ AutoVacLauncherMain(const void *startup_data, size_t startup_data_len)
*/
current_time = GetCurrentTimestamp();
+ if (current_time < last_current_time)
+ {
+ /*
+ * The clock jumped backwards so reschedule the workers so that
+ * databases won't stop getting auto-vacuumed.
+ */
+ rebuild_database_list(InvalidOid);
+ }
+ last_current_time = current_time;
+
LWLockAcquire(AutovacuumLock, LW_SHARED);
can_launch = av_worker_available();
--
2.43.0
________________________________________
From: Cliff Clark <Cliff_Clark(at)selinc(dot)com>
Sent: Wednesday, March 25, 2026 9:21
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: [PATCH] Auto vacuum should still run when clock is set back
[Caution - External]
The clock changes are not due to DST, but the UTC system time. There was an NTP server on an offline network that went from 2019 to 2006 due to GPS week number rollover. The date being wrong did cause some problems, but nothing fatal, but several machines filled up their disk to the point of failure because autovacuum was no longer running.
I will attempt to attach the patch again.
________________________________________
From: Michael Paquier <michael(at)paquier(dot)xyz>
Sent: Tuesday, March 24, 2026 18:55
To: Cliff Clark <Cliff_Clark(at)selinc(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: [PATCH] Auto vacuum should still run when clock is set back
[You don't often get email from michael(at)paquier(dot)xyz(dot) Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
[Caution - External]
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Peter Eisentraut | 2026-03-25 16:27:34 | Re: remove bits* types |
| Previous Message | Cliff Clark | 2026-03-25 16:21:52 | Re: [PATCH] Auto vacuum should still run when clock is set back |