pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ron <ronljohnsonjr@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 17:13:29 -0600
Message-ID: <d879c78d-5c4a-51a3-8b19-4c823504441e@gmail.com> (raw)
In-Reply-To: <016ec140-b1eb-a3cb-a1ac-d90ceae0d950@gmail.com>
References: <CADpeV5xCiU_arY4gS6dtQqL2-7trLeLpn3GF_+k3dJ3dhb5JbA@mail.gmail.com>
	<4cd35a2737cc783662f1df14551c3dcb1bf55916.camel@cybertec.at>
	<5be65cbc-b181-f89d-32e4-8efd58d49f73@gmail.com>
	<016ec140-b1eb-a3cb-a1ac-d90ceae0d950@gmail.com>

On 1/16/23 15:46, Rob Sargent wrote:
> On 1/16/23 14:18, Ron wrote:
>> On 1/16/23 07:11, Laurenz Albe wrote:
>>> 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".
>>
>> So OP should VACUUM FREEZE the table.
>>
> Hm, did OP say there was an actual problem as is?  Or just a "puzzle" - 
> now explained - and no action is necessary?
>

"Should" as in "it's a good idea", not "it's important but not vital".

-- 
Born in Arizona, moved to Babylonia.

view thread (6+ messages)

Message-ID: <d879c78d-5c4a-51a3-8b19-4c823504441e@gmail.com>
Permalink:  ../d879c78d-5c4a-51a3-8b19-4c823504441e@gmail.com/
Also on:    postgresql.org/message-id/d879c78d-5c4a-51a3-8b19-4c823504441e@gmail.com

 · 

reply

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: ronljohnsonjr@gmail.com
  Subject: Re: Why is a Read-only Table Gets Autovacuumed "to prevent wraparound"
  In-Reply-To: <d879c78d-5c4a-51a3-8b19-4c823504441e@gmail.com>
  References: <CADpeV5xCiU_arY4gS6dtQqL2-7trLeLpn3GF_+k3dJ3dhb5JbA@mail.gmail.com> <4cd35a2737cc783662f1df14551c3dcb1bf55916.camel@cybertec.at> <5be65cbc-b181-f89d-32e4-8efd58d49f73@gmail.com> <016ec140-b1eb-a3cb-a1ac-d90ceae0d950@gmail.com> <d879c78d-5c4a-51a3-8b19-4c823504441e@gmail.com>

* 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