postgresql/src/backend
Robert Haas a734fd5d1c 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@mail.gmail.com

Michael Paquier, with a bunch of comment changes by me.
2016-11-21 13:01:50 -05:00
..
access Remove or reduce verbosity of some debug messages. 2016-11-17 17:05:16 -05:00
bootstrap Fix a bunch of places that called malloc and friends with no NULL check. 2016-08-30 18:22:43 -04:00
catalog Add pg_sequences view 2016-11-18 14:59:03 -05:00
commands Add pg_sequences view 2016-11-18 14:59:03 -05:00
executor Simplify code by getting rid of SPI_push, SPI_pop, SPI_restore_connection. 2016-11-08 17:39:57 -05:00
foreign Remove GetUserMappingId() and GetUserMappingById(). 2016-07-22 11:32:23 -04:00
lib Clarify the new Red-Black post-order traversal code a bit. 2016-09-04 15:02:06 +03:00
libpq Consistently mention 'SELECT pg_reload_conf()' in config files 2016-10-25 11:26:15 -04:00
main Repair a bit of pgindent damage. 2016-06-09 18:09:17 -04:00
nodes Implement syntax for transition tables in AFTER triggers. 2016-11-04 10:49:50 -05:00
optimizer Fix test for subplans in force-parallel mode. 2016-11-21 11:09:24 -05:00
parser Prevent multicolumn expansion of "foo.*" in an UPDATE source expression. 2016-11-20 14:26:19 -05:00
po Translation updates 2016-08-08 11:08:00 -04:00
port Try to find out the actual hugepage size when making a MAP_HUGETLB request. 2016-10-13 15:06:46 -04:00
postmaster autovacuum: Drop orphan temp tables more quickly but with more caution. 2016-11-21 13:01:50 -05:00
regex Make locale-dependent regex character classes work for large char codes. 2016-09-05 17:06:29 -04:00
replication Fix typos in comments. 2016-10-26 11:12:31 +03:00
rewrite Cleanup of rewriter and planner handling of Query.hasRowSecurity flag. 2016-11-10 16:16:33 -05:00
snowball Update copyright for 2016 2016-01-02 13:33:40 -05:00
storage Reserve zero as an invalid DSM handle. 2016-11-15 16:33:29 -05:00
tcop Remove or reduce verbosity of some debug messages. 2016-11-17 17:05:16 -05:00
tsearch Add macros to make AllocSetContextCreate() calls simpler and safer. 2016-08-27 17:50:38 -04:00
utils Code review for GUC serialization/deserialization code. 2016-11-19 14:26:19 -05:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
common.mk Remove maintainer-check target, fold into normal build 2013-10-10 20:11:56 -04:00
Makefile Refer to OS X as "macOS", except for the port name which is still "darwin". 2016-09-25 15:40:57 -04:00
nls.mk Remove trailing slashes from directories in find command 2015-09-18 22:06:54 -04:00