postgresql/src/backend/access
Michael Paquier 246a6c8f7b 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.
2018-08-13 11:49:04 +02:00
..
brin Fail BRIN control functions during recovery explicitly 2018-06-14 12:51:32 -04:00
common Improve performance of tuple conversion map generation 2018-07-13 19:54:05 +03:00
gin Fix handling of empty uncompressed posting list pages in GIN 2018-07-19 21:04:17 +03:00
gist Provide separate header file for built-in float types 2018-07-29 03:30:48 +02:00
hash Clean up warnings from -Wimplicit-fallthrough. 2018-05-01 19:35:08 -04:00
heap Reset properly errno before calling write() 2018-08-05 05:31:18 +09:00
index Revise BuildIndexValueDescription to simplify it 2018-07-16 20:20:15 -04:00
nbtree Reduce path length for locking leaf B-tree pages during insertion 2018-07-28 00:31:40 +03:00
rmgrdesc printf("%lf") is not portable, so omit the "l". 2018-05-20 11:40:54 -04:00
spgist Fix typo in SP-GiST error message 2018-08-10 17:28:48 +03:00
tablesample Rethink how to get float.h in old Windows API for isnan/isinf 2018-07-11 09:11:48 -04:00
transam Make autovacuum more aggressive to remove orphaned temp tables 2018-08-13 11:49:04 +02:00
Makefile TABLESAMPLE, SQL Standard and extensible 2015-05-15 14:37:10 -04:00