Re: Autovacuum to prevent wraparound tries to consume xid

Alexander Korotkov <a.korotkov@postgrespro.ru>

From: Alexander Korotkov <a.korotkov@postgrespro.ru>
To: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2016-05-19T14:14:31Z
Lists: pgsql-hackers

Attachments

On Mon, Mar 28, 2016 at 2:05 PM, Alexander Korotkov <
a.korotkov@postgrespro.ru> wrote:

> After some debugging I found that vac_truncate_clog consumes xid just to
> produce warning.  I wrote simple patch which replaces
> GetCurrentTransactionId() with ShmemVariableCache->nextXid.  That
> completely fixes this situation for me: ShmemVariableCache was successfully
> updated.
>

I found that direct reading of ShmemVariableCache->nextXid is not corrent,
it's better to use ReadNewTransactionId() then.  Fixed version of patch is
attached.

------
Alexander Korotkov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company

Commits

  1. Avoid repeating loads of frozen ID values.

  2. Close race condition between datfrozen and relfrozen updates.

  3. Fetch XIDs atomically during vac_truncate_clog().