Change ANALYZE to take ShareUpdateExclusiveLock not AccessShareLock on

Tom Lane <tgl@sss.pgh.pa.us>

Commit: da7540b9d17c09c3b2e49a7580e5f42dcc4a4bcd
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: 2006-09-17T22:50:31Z
Releases: 8.2.0
Change ANALYZE to take ShareUpdateExclusiveLock not AccessShareLock on
the table being analyzed.  This prevents two ANALYZEs from running
concurrently on the same table and possibly suffering concurrent-update
failures while trying to store their results into pg_statistic.  The
downside is that a database-wide ANALYZE executed within a transaction
block will hold ShareUpdateExclusiveLock on many tables simultaneously,
which could lead to concurrency issues or even deadlock against another
such ANALYZE.  However, this seems a corner case of less importance
than getting unexpected errors from a foreground ANALYZE when autovacuum
elects to analyze the same table concurrently.  Per discussion.

Files

PathChange+/−
doc/src/sgml/mvcc.sgml modified +182 −183
src/backend/commands/analyze.c modified +19 −19