From: | Robert Haas <rhaas(at)postgresql(dot)org> |
---|---|
To: | pgsql-committers(at)postgresql(dot)org |
Subject: | pgsql: autovacuum: Drop orphan temp tables more quickly but with more c |
Date: | 2016-11-21 18:05:40 |
Message-ID: | E1c8syK-0000KH-I1@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers pgsql-hackers |
autovacuum: Drop orphan temp tables more quickly but with more caution.
Previously, we only dropped an orphan temp table when it became old
enough to threaten wraparound; instead, doing it immediately. The
only value of waiting is that someone might be able to examine the
contents of the orphan temp table for forensic purposes, but it's
pretty difficult to actually do that and few users will wish to do so.
On the flip side, not performing the drop immediately generates log
spam and bloats pg_class.
In addition, per a report from Grigory Smolkin, if a temporary schema
contains a very large number of temporary tables, a backend attempting
to clear the temporary schema might fail due to lock table exhaustion.
It's helpful for autovacuum to clean up after such cases, and we don't
want it to wait for wraparound to threaten before doing so. To
prevent autovacuum from failing in the same manner as a backend trying
to drop an entire temp schema, remove orphan temp tables in batches of
50, committing after each batch, so that we don't accumulate an
unbounded number of locks. If a drop fails, retry other orphan tables
that need to be dropped up to 10 times before giving up. With this
system, if a backend does fail to clean a temporary schema due to
lock table exhaustion, autovacuum should hopefully put things right
the next time it processes the database.
Discussion: CAB7nPqSbYT6dRwsXVgiKmBdL_ARemfDZMPA+RPeC_ge0GK70hA(at)mail(dot)gmail(dot)com
Michael Paquier, with a bunch of comment changes by me.
Branch
------
master
Details
-------
http://git.postgresql.org/pg/commitdiff/a734fd5d1c309cc553b7c8c79fba96218af090f7
Modified Files
--------------
src/backend/postmaster/autovacuum.c | 153 ++++++++++++++++++++++++++++++------
1 file changed, 127 insertions(+), 26 deletions(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2016-11-21 18:19:34 | pgsql: Fix optimization for skipping searches for parallel-query hazard |
Previous Message | Tom Lane | 2016-11-21 16:09:39 | pgsql: Fix test for subplans in force-parallel mode. |
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2016-11-21 18:06:08 | Re: Fun fact about autovacuum and orphan temp tables |
Previous Message | Tom Lane | 2016-11-21 18:00:12 | Re: [sqlsmith] Parallel worker crash on seqscan |