pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Laurenz Albe <laurenz.albe@cybertec.at>
To: Don Seiler <don@seiler.us>
To: Postgres General <pgsql-general@postgresql.org>
Subject: Re: template0 needing vacuum freeze?
Date: Mon, 18 May 2020 08:40:26 +0200
Message-ID: <bc9b99b68cb8746a8440935bcb87e38440adbaaf.camel@cybertec.at> (raw)
In-Reply-To: <CAHJZqBAGheciTgcKZ9J=Q=A+CdtH0LOUbtqsX8nSvBS1RKggQg@mail.gmail.com>
References: <CAHJZqBAGheciTgcKZ9J=Q=A+CdtH0LOUbtqsX8nSvBS1RKggQg@mail.gmail.com>

On Sat, 2020-05-16 at 12:19 -0500, Don Seiler wrote:
> PG 9.6 (9.6.8). Got an alert today when template0 and template1 were both over 50%
> towards TXID wraparound. I could vacuum template1 but couldn't vacuum template0
> without first allowing connections. This is what it looked like before:
> 
> # SELECT datname
>     , age(datfrozenxid)
>     , current_setting('autovacuum_freeze_max_age')
> FROM pg_database
> ORDER BY 2 DESC;
>       datname       |    age     | current_setting
> --------------------+------------+-----------------
>  foo_db             | 1022106099 | 200000000
>  template0          | 1000278345 | 200000000
>  postgres           |     643729 | 200000000
>  template1          |     643729 | 200000000
> (4 rows)
> 
> I've since allowed connections and ran "vacuumdb --freeze" on it and then immediately
> disabled the connections to it again. But I'm curious how template0 would be growing
> in age like this. Even now I see the template0 age growing.

That is indeed strange.

Did you see any weird messages when you vacuumed "template0"?
Did "datfrozenxid" shrink after the operation?

"foo_db" seems to be the bigger problem.
Perhaps autovacuum never handled "template0" because it concluded (rightly) that
it has to deal with "foo_db" first.

> I can say that these DB
> has previously been altered for locale changes as well.

Would you care to explain that?  You changed "template0"?  How?

> I'm also running a long "vacuum freeze" on foo_db that will take a few days after
> seeing that autovacuum on a big table had been running on it since Feb 2 and making
> no progress, with over 850M dead tuples according to pg_stat_all_tables.
> I estimate 3-4 more days to go on that one. Once that's done I'll be scheduling
> manual vacuum jobs. Just wondering if that would somehow affect regular template0
> cleanup though.

As I said, perhaps.

What are your non-default autovacuum settings?  Perhaps you should speed up autovacuum
by reducing "autovacuum_vacuum_cost_delay" to 2ms or less, and by increasing
"maintenance_work_mem".

Yours,
Laurenz Albe
-- 
Cybertec | https://www.cybertec-postgresql.com






view thread (8+ messages)  latest in thread

Message-ID: <bc9b99b68cb8746a8440935bcb87e38440adbaaf.camel@cybertec.at>
Permalink:  ../bc9b99b68cb8746a8440935bcb87e38440adbaaf.camel@cybertec.at/
Also on:    postgresql.org/message-id/bc9b99b68cb8746a8440935bcb87e38440adbaaf.camel@cybertec.at

 · 

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: laurenz.albe@cybertec.at, don@seiler.us
  Subject: Re: template0 needing vacuum freeze?
  In-Reply-To: <bc9b99b68cb8746a8440935bcb87e38440adbaaf.camel@cybertec.at>
  References: <CAHJZqBAGheciTgcKZ9J=Q=A+CdtH0LOUbtqsX8nSvBS1RKggQg@mail.gmail.com> <bc9b99b68cb8746a8440935bcb87e38440adbaaf.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