postgresql/src
Kevin Grittner b19e4250b4 Fix performance problems with autovacuum truncation in busy workloads.
In situations where there are over 8MB of empty pages at the end of
a table, the truncation work for trailing empty pages takes longer
than deadlock_timeout, and there is frequent access to the table by
processes other than autovacuum, there was a problem with the
autovacuum worker process being canceled by the deadlock checking
code. The truncation work done by autovacuum up that point was
lost, and the attempt tried again by a later autovacuum worker. The
attempts could continue indefinitely without making progress,
consuming resources and blocking other processes for up to
deadlock_timeout each time.

This patch has the autovacuum worker checking whether it is
blocking any other thread at 20ms intervals. If such a condition
develops, the autovacuum worker will persist the work it has done
so far, release its lock on the table, and sleep in 50ms intervals
for up to 5 seconds, hoping to be able to re-acquire the lock and
try again. If it is unable to get the lock in that time, it moves
on and a worker will try to continue later from the point this one
left off.

While this patch doesn't change the rules about when and what to
truncate, it does cause the truncation to occur sooner, with less
blocking, and with the consumption of fewer resources when there is
contention for the table's lock.

The only user-visible change other than improved performance is
that the table size during truncation may change incrementally
instead of just once.

This problem exists in all supported versions but is infrequently
reported, although some reports of performance problems when
autovacuum runs might be caused by this. Initial commit is just the
master branch, but this should probably be backpatched once the
build farm and general developer usage confirm that there are no
surprising effects.

Jan Wieck
2012-12-11 14:33:08 -06:00
..
backend Fix performance problems with autovacuum truncation in busy workloads. 2012-12-11 14:33:08 -06:00
bin Fix assorted bugs in privileges-for-types patch. 2012-12-09 00:08:23 -05:00
include Fix performance problems with autovacuum truncation in busy workloads. 2012-12-11 14:33:08 -06:00
interfaces Include isinf.o in libecpg if isinf() is not available on the system. 2012-12-04 16:44:22 +01:00
makefiles Add mode where contrib installcheck runs each module in a separately named database. 2012-12-11 11:52:45 -05:00
pl Improve pl/pgsql to support composite-type expressions in RETURN. 2012-12-06 23:09:52 -05:00
port Remove redundant code for getnameinfo() replacement 2012-10-04 21:45:14 -04:00
template Remove _FORTIFY_SOURCE 2012-10-10 21:42:38 -04:00
test Support automatically-updatable views. 2012-12-08 18:26:21 -05:00
timezone Update time zone data files to tzdata release 2012j. 2012-12-02 16:35:23 -05:00
tools Adjust find_status for newer Linux 'nm' output format. 2012-11-13 21:08:07 -05:00
tutorial Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
.gitignore
bcc32.mak Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
DEVELOPERS
Makefile
Makefile.global.in Add mode where contrib installcheck runs each module in a separately named database. 2012-12-11 11:52:45 -05:00
Makefile.shlib Remove configure flag --disable-shared, as it is no longer used by any 2012-08-30 16:26:53 -04:00
nls-global.mk Lots of doc corrections. 2012-04-23 22:43:09 -04:00
win32.mak Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00