OSDN Git Service

Prevent incorrect updates of pg_index while reindexing pg_index itself.
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 16 Apr 2011 00:18:57 +0000 (20:18 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 16 Apr 2011 00:18:57 +0000 (20:18 -0400)
commit4b6106ccfea21e86943f881edcf3cfc03661a415
tree19ae5026e724e1f67774d87e5a3d441328a6c1a2
parentff5565f0a4aa3c584792d220a3e566369a77f479
Prevent incorrect updates of pg_index while reindexing pg_index itself.

The places that attempt to change pg_index.indcheckxmin during a reindexing
operation cannot be executed safely if pg_index itself is the subject of
the operation.  This is the explanation for a couple of recent reports of
VACUUM FULL failing with
ERROR:  duplicate key value violates unique constraint "pg_index_indexrelid_index"
DETAIL:  Key (indexrelid)=(2678) already exists.

However, there isn't any real need to update indcheckxmin in such a
situation, if we assume that pg_index can never contain a truly broken HOT
chain.  This assumption holds if new indexes are never created on it during
concurrent operations, which is something we don't consider safe for any
system catalog, not just pg_index.  Accordingly, modify the code to not
manipulate indcheckxmin when reindexing any system catalog.

Back-patch to 8.3, where HOT was introduced.  The known failure scenarios
involve 9.0-style VACUUM FULL, so there might not be any real risk before
9.0, but let's not assume that.
src/backend/catalog/index.c