| From: | Baji Shaik <baji(dot)pgdev(at)gmail(dot)com> |
|---|---|
| To: | PostgreSQL-development <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Cc: | Nathan Bossart <nathandbossart(at)gmail(dot)com> |
| Subject: | Autovacuum freeze scores wrap around for just-vacuumed tables |
| Date: | 2026-11-11 14:47:10 |
| Message-ID: | CA+fm-RPOMc-GHjpv4DpXO1eqMahCeZDpAgXWqVgnsB3s3arptA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
relation_needs_vacanalyze() computes the freeze score ages as
recentXid - relfrozenxid and recentMulti - relminmxid, but both are
read before pg_class is scanned. If a table's relfrozenxid or
relminmxid advances in between, for example by a concurrent VACUUM or
a table rewrite, the subtraction wraps to about 4 billion and the
just-vacuumed table gets a score around 1e44, which can put it at the
front of autovacuum's list. The window grows with the number of
relations; with a few thousand tables, pg_stat_autovacuum_scores shows
it hundreds of times a minute.
0001 treats the age as zero in that case. 0002 is a TAP test, using
the existing autovacuum-worker-start injection point, that shows it for
an autovacuum worker; it's for the record rather than for commit.
Please find the attached patches. Thoughts?
Regards,
Baji Shaik
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0002-Add-a-test-for-the-autovacuum-freeze-score-wrapar.patch | application/octet-stream | 4.5 KB |
| v1-0001-Fix-wraparound-of-the-ages-used-for-autovacuum-fr.patch | application/octet-stream | 2.4 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Matheus Alcantara | 2026-11-11 14:54:36 | Re: Wrong result for whole-row IS NOT NULL with dropped columns |
| Previous Message | he kuang | 2026-11-11 14:42:32 | Re: [PATCH 0/2] Fix two hash join costing errors in final_cost_hashjoin() |