From: Cliff Clark =0A= Date: Tue, 24 Mar 2026 11:32:43 -0700=0A= Subject: [PATCH] Autovacuum should still run when clock is set back=0A= =0A= Add code to detect when the clock was set back since the last autovacuum=0A= launcher run. When this happens, rebuild the database list so that=0A= autovacuum will continue to run.=0A= ---=0A= src/backend/postmaster/autovacuum.c | 17 +++++++++++++++++=0A= 1 file changed, 17 insertions(+)=0A= =0A= diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/a= utovacuum.c=0A= index 219673db930..9f2c6434802 100644=0A= --- a/src/backend/postmaster/autovacuum.c=0A= +++ b/src/backend/postmaster/autovacuum.c=0A= @@ -377,6 +377,7 @@ void=0A= AutoVacLauncherMain(const void *startup_data, size_t startup_data_len)=0A= {=0A= sigjmp_buf local_sigjmp_buf;=0A= + TimestampTz last_current_time;=0A= =0A= Assert(startup_data_len =3D=3D 0);=0A= =0A= @@ -568,6 +569,12 @@ AutoVacLauncherMain(const void *startup_data, size_t s= tartup_data_len)=0A= =0A= AutoVacuumShmem->av_launcherpid =3D MyProcPid;=0A= =0A= + /*=0A= + * Set the initial last run time to just before we build the worker=0A= + * schedule.=0A= + */=0A= + last_current_time =3D GetCurrentTimestamp();=0A= +=0A= /*=0A= * Create the initial database list. The invariant we want this list to= =0A= * keep is that it's ordered by decreasing next_worker. As soon as an=0A= @@ -649,6 +656,16 @@ AutoVacLauncherMain(const void *startup_data, size_t s= tartup_data_len)=0A= */=0A= =0A= current_time =3D GetCurrentTimestamp();=0A= + if (current_time < last_current_time)=0A= + {=0A= + /*=0A= + * The clock jumped backwards so reschedule the workers so that=0A= + * databases won't stop getting auto-vacuumed.=0A= + */=0A= + rebuild_database_list(InvalidOid);=0A= + }=0A= + last_current_time =3D current_time;=0A= +=0A= LWLockAcquire(AutovacuumLock, LW_SHARED);=0A= =0A= can_launch =3D av_worker_available();=0A= -- =0A= 2.43.0=0A= =0A= =0A= ________________________________________=0A= From:=A0Cliff Clark =0A= Sent:=A0Wednesday, March 25, 2026 9:21=0A= To:=A0Michael Paquier =0A= Cc:=A0pgsql-hackers@lists.postgresql.org =0A= Subject:=A0Re: [PATCH] Auto vacuum should still run when clock is set back= =0A= =A0=0A= [Caution - External]=0A= =0A= 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 we= ek number rollover. The date being wrong did cause some problems, but nothi= ng fatal, but several machines filled up their disk to the point of failure= because autovacuum was no longer running.=0A= =0A= I will attempt to attach the patch again.=0A= =0A= ________________________________________=0A= From: Michael Paquier =0A= Sent: Tuesday, March 24, 2026 18:55=0A= To: Cliff Clark =0A= Cc: pgsql-hackers@lists.postgresql.org = =0A= Subject: Re: [PATCH] Auto vacuum should still run when clock is set back=0A= =0A= [You don't often get email from michael@paquier.xyz. Learn why this is impo= rtant at https://aka.ms/LearnAboutSenderIdentification=A0]=0A= =0A= [Caution - External]=