pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jehan-Guillaume de Rorthais <jgdr@dalibo.com>
To: Luca Ferrari <fluca1978@gmail.com>
Cc: pgsql-general <pgsql-general@lists.postgresql.org>
Subject: Re: questions about wraparound
Date: Fri, 2 Apr 2021 10:29:00 +0200
Message-ID: <20210402102900.7ae6e665@firost> (raw)
In-Reply-To: <CAKoxK+5yPtx3-VOea_GJPp5fNHXc+EnGPUkBSh3ccx3B+0Sd=w@mail.gmail.com>
References: <CAKoxK+5yPtx3-VOea_GJPp5fNHXc+EnGPUkBSh3ccx3B+0Sd=w@mail.gmail.com>

On Thu, 18 Mar 2021 09:56:16 +0100
Luca Ferrari <fluca1978@gmail.com> wrote:
[...]
> Therefore my question is: shouldn't autovacuum be able to freeze other
> tables/databases? I mean, the wraparound problem in this scenario will
> cause problems, but I was expecting different numbers for different
> tables/databases.

In fact, when an autovacuum worker is spawned, here is how it chooses what
database to process:

1. look for any database needing a vacuum to prevent a wraparound.
2. same with multi-transaction
3. other autovacuum considerations

So as long as there's a database in desperate need for a vacuum to prevent a
wraparound, a worker will try to process it first, again and again.

Because of your long-running transaction, the xid horizon forbid to update the
rel/datfrozenxid. So next autovacuum round will keep trying to process the same
database, ignoring others.

Look at the comment in function "do_stat_worker()" in autovacuum.c for more
details:
https://git.postgresql.org/cgit/postgresql.git/tree/src/backend/postmaster/autovacuum.c#n1207

When looping over the database list, as soon as "for_xid_wrap" is true, any
other database is ignored. Then a new worker is popped from the freeWorkers,
init'ed with the database to freeze and started. So as far as I understand the
code (I might easily be wrong), all the workers will keep trying to process the
same database again and again without considering other ones. All because of
your really-long living xact.

Regards,





view thread (14+ messages)  latest in thread

Message-ID: <20210402102900.7ae6e665@firost>
Permalink:  ../20210402102900.7ae6e665@firost/
Also on:    postgresql.org/message-id/20210402102900.7ae6e665@firost

 · 

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: jgdr@dalibo.com, fluca1978@gmail.com
  Subject: Re: questions about wraparound
  In-Reply-To: <20210402102900.7ae6e665@firost>
  References: <CAKoxK+5yPtx3-VOea_GJPp5fNHXc+EnGPUkBSh3ccx3B+0Sd=w@mail.gmail.com> <20210402102900.7ae6e665@firost>

* 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