pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Make autovacuum more aggressive to remove orphaned temp tables
Date: Mon, 13 Aug 2018 09:50:50 +0000
Message-ID: <E1fp9Uw-0006vW-PJ@gemulon.postgresql.org> (raw)

Make autovacuum more aggressive to remove orphaned temp tables

Commit dafa084, added in 10, made the removal of temporary orphaned
tables more aggressive.  This commit makes an extra step into the
aggressiveness by adding a flag in each backend's MyProc which tracks
down any temporary namespace currently in use.  The flag is set when the
namespace gets created and can be reset if the temporary namespace has
been created in a transaction or sub-transaction which is aborted.  The
flag value assignment is assumed to be atomic, so this can be done in a
lock-less fashion like other flags already present in PGPROC like
databaseId or backendId, still the fact that the temporary namespace and
table created are still locked until the transaction creating those
commits acts as a barrier for other backends.

This new flag gets used by autovacuum to discard more aggressively
orphaned tables by additionally checking for the database a backend is
connected to as well as its temporary namespace in-use, removing
orphaned temporary relations even if a backend reuses the same slot as
one which created temporary relations in a past session.

The base idea of this patch comes from Robert Haas, has been written in
its first version by Tsunakawa Takayuki, then heavily reviewed by me.

Author: Tsunakawa Takayuki
Reviewed-by: Michael Paquier, Kyotaro Horiguchi, Andres Freund
Discussion: https://postgr.es/m/0A3221C70F24FB45833433255569204D1F8A4DC6@G01JPEXMBYT05
Backpatch: 11-, as PGPROC gains a new flag and we don't want silent ABI
breakages on already released versions.

Branch
------
REL_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/943576bddcb52971041d9f5f806789921fa107ee

Modified Files
--------------
src/backend/access/transam/twophase.c |  1 +
src/backend/catalog/namespace.c       | 70 ++++++++++++++++++++++++++++++++++-
src/backend/postmaster/autovacuum.c   | 20 ++++------
src/backend/storage/lmgr/proc.c       |  2 +
src/include/catalog/namespace.h       |  1 +
src/include/storage/proc.h            |  3 ++
6 files changed, 83 insertions(+), 14 deletions(-)



view thread (2+ messages)

Message-ID: <E1fp9Uw-0006vW-PJ@gemulon.postgresql.org>
Permalink:  ../E1fp9Uw-0006vW-PJ@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1fp9Uw-0006vW-PJ@gemulon.postgresql.org

 · 

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-committers@postgresql.org
  Cc: michael@paquier.xyz
  Subject: Re: pgsql: Make autovacuum more aggressive to remove orphaned temp tables
  In-Reply-To: <E1fp9Uw-0006vW-PJ@gemulon.postgresql.org>
  References: <E1fp9Uw-0006vW-PJ@gemulon.postgresql.org>

* 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