From: Laurenz Albe <laurenz.albe@cybertec.at>
To: Fred Habash <fmhabash@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: Why is a Read-only Table Gets Autovacuumed "to prevent wraparound"
Date: Mon, 16 Jan 2023 14:11:58 +0100
Message-ID: <4cd35a2737cc783662f1df14551c3dcb1bf55916.camel@cybertec.at> (raw)
In-Reply-To: <CADpeV5xCiU_arY4gS6dtQqL2-7trLeLpn3GF_+k3dJ3dhb5JbA@mail.gmail.com>
References: <CADpeV5xCiU_arY4gS6dtQqL2-7trLeLpn3GF_+k3dJ3dhb5JbA@mail.gmail.com>
On Mon, 2023-01-16 at 07:48 -0500, Fred Habash wrote:
> This is a puzzle I have not been able to crack yet.
>
> We have a single-page table with 28 rows that is purely read-only. There isn't a way in postgres to make a table RO, but I say this with confidence because pg_stat_user_tables has always showed 0
> updates/deletes/inserts.
>
> Furthermore, the schema app developers know, for certain, this table does not get changed at all.
>
> We installed scripts that run every few minutes that do a 'select *' and over a period of days, we have not seen a change.
>
> We disabled autovacuum on this table '{autovacuum_enabled=false}'. But, despite the fact that this table is read-only (by design) and autovac id is disabled, it got autovac'd twice in less than 10
> days and on both occasions, pg_stat_activity showed the worker with 'to prevent wraparound'. This explains why autovac did not honor the disabled status.
>
> But why is this table autovac'd at all?
For every table PostgreSQL stores the oldest transaction ID in an unfrozen tuple
in "pg_class.relfrozenxid". Once that is more than "autovacuum_freeze_max_age",
the table gets autovacuumed. If the table is already all-frozen, that is a short
operation and will just advance "pg_class.relfrozenxid".
Yours,
Laurenz Albe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: laurenz.albe@cybertec.at, fmhabash@gmail.com
Subject: Re: Why is a Read-only Table Gets Autovacuumed "to prevent wraparound"
In-Reply-To: <4cd35a2737cc783662f1df14551c3dcb1bf55916.camel@cybertec.at>
References: <CADpeV5xCiU_arY4gS6dtQqL2-7trLeLpn3GF_+k3dJ3dhb5JbA@mail.gmail.com> <4cd35a2737cc783662f1df14551c3dcb1bf55916.camel@cybertec.at>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox