Ensure ANALYZE phase is not skipped because of canceled truncate.
authorKevin Grittner <kgrittn@postgresql.org>
Mon, 29 Apr 2013 18:06:28 +0000 (13:06 -0500)
committerKevin Grittner <kgrittn@postgresql.org>
Mon, 29 Apr 2013 18:06:28 +0000 (13:06 -0500)
commit93641341f0993131dfb90aa7ac4add3305d00b9c
tree2cf1dc95acf1ef6ece4df9506ccb913347c8e8d4
parent359c8e4545a0d67465205353bd0b086aedbf5293
Ensure ANALYZE phase is not skipped because of canceled truncate.

Patch b19e4250b45e91c9cbdd18d35ea6391ab5961c8d attempted to
preserve existing behavior regarding statistics generation in the
case that a truncation attempt was canceled due to lock conflicts.
It failed to do this accurately in two regards: (1) autovacuum had
previously generated statistics if the truncate attempt failed to
initially get the lock rather than having started the attempt, and
(2) the VACUUM ANALYZE command had always generated statistics.

Both of these changes were unintended, and are reverted by this
patch.  On review, there seems to be consensus that the previous
failure to generate statistics when the truncate was terminated
was more an unfortunate consequence of how that effort was
previously terminated than a feature we want to keep; so this
patch generates statistics even when an autovacuum truncation
attempt terminates early.  Another unintended change which is kept
on the basis that it is an improvement is that when a VACUUM
command is truncating, it will the new heuristic for avoiding
blocking other processes, rather than keeping an
AccessExclusiveLock on the table for however long the truncation
takes.

Per multiple reports, with some renaming per patch by Jeff Janes.

Backpatch to 9.0, where problem was created.
src/backend/commands/vacuumlazy.c