pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Make autovacuum more aggressive to remove orphaned temp tables
2+ messages / 1 participants
[nested] [flat]

* pgsql: Make autovacuum more aggressive to remove orphaned temp tables
@ 2018-08-13 09:50  Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 2+ messages in thread

From: Michael Paquier @ 2018-08-13 09:50 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/246a6c8f7b237cc1943efbbb8a7417da9288f5c4

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(-)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* pgsql: Make autovacuum more aggressive to remove orphaned temp tables
@ 2018-08-13 09:50  Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 2+ messages in thread

From: Michael Paquier @ 2018-08-13 09:50 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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(-)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2018-08-13 09:50 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-08-13 09:50 pgsql: Make autovacuum more aggressive to remove orphaned temp tables Michael Paquier <michael@paquier.xyz>
2018-08-13 09:50 pgsql: Make autovacuum more aggressive to remove orphaned temp tables Michael Paquier <michael@paquier.xyz>

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