Re: Another fun fact about temp tables and wraparound - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: Another fun fact about temp tables and wraparound
Date
Msg-id 20180717144608.bphejyvdfy5l2hnf@alvherre.pgsql
Whole thread Raw
In response to Another fun fact about temp tables and wraparound  (Grigory Smolkin <g.smolkin@postgrespro.ru>)
List pgsql-hackers
On 2018-Jul-17, Grigory Smolkin wrote:

> Hello, hackers!
> 
> Recently I was investigating the case of 'stuck in wraparaound' problem.
> PostgreSQL instance(9.6.9) in question reached 'million-before-wraparound'
> threshold and switched to read-only mode.
> Running vacuum in single-mode gives not results, datfrozenxid was not
> advancing:
> 
> backend> vacuum freeze;
> 2018-07-13 16:43:58 MSK [3666-3] WARNING:  database "database_name" must be
> vacuumed within 991565 transactions
> 2018-07-13 16:43:58 MSK [3666-4] HINT:  To avoid a database shutdown,
> execute a database-wide VACUUM in that database.
>         You might also need to commit or roll back old prepared
> transactions.
> backend>
> 
> pg_prepared_xacts was empty.
> After some poking around it became clear that some old temp table was
> holding the oldest relfrozenxid!

Hmm, autovacuum is supposed to drop temp tables that are above the
wraparound xid age to avoid this problem -- see autovacuum lines 2046ff.
(Except it doesn't do anything if the owning backend is active.  I guess
this could be a problem if the owning backend fails to do anything about
those tables.  Maybe this part is a mistake.)  Obviously, during
single-user mode autovacuum doesn't run anyway.

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


pgsql-hackers by date:

Previous
From: Grigory Smolkin
Date:
Subject: Another fun fact about temp tables and wraparound
Next
From: Daniel Gustafsson
Date:
Subject: Re: Allow auto_explain to log to NOTICE