From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-committers(at)postgresql(dot)org |
Subject: | pgsql: Fix assorted bugs in CREATE INDEX CONCURRENTLY. |
Date: | 2012-11-29 19:52:53 |
Message-ID: | E1TeAAH-00082e-DS@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
Fix assorted bugs in CREATE INDEX CONCURRENTLY.
This patch changes CREATE INDEX CONCURRENTLY so that the pg_index
flag changes it makes without exclusive lock on the index are made via
heap_inplace_update() rather than a normal transactional update. The
latter is not very safe because moving the pg_index tuple could result in
concurrent SnapshotNow scans finding it twice or not at all, thus possibly
resulting in index corruption.
In addition, fix various places in the code that ought to check to make
sure that the indexes they are manipulating are valid and/or ready as
appropriate. These represent bugs that have existed since 8.2, since
a failed CREATE INDEX CONCURRENTLY could leave a corrupt or invalid
index behind, and we ought not try to do anything that might fail with
such an index.
Also fix RelationReloadIndexInfo to ensure it copies all the pg_index
columns that are allowed to change after initial creation. Previously we
could have been left with stale values of some fields in an index relcache
entry. It's not clear whether this actually had any user-visible
consequences, but it's at least a bug waiting to happen.
This is a subset of a patch already applied in 9.2 and HEAD. Back-patch
into all earlier supported branches.
Tom Lane and Andres Freund
Branch
------
REL9_0_STABLE
Details
-------
http://git.postgresql.org/pg/commitdiff/1dbd02dc37efb74b770aa834b2cb65dae2446640
Modified Files
--------------
src/backend/access/heap/README.HOT | 6 ++
src/backend/catalog/index.c | 141 ++++++++++++++++++++++++++++------
src/backend/commands/cluster.c | 10 ++-
src/backend/commands/indexcmds.c | 41 +---------
src/backend/commands/tablecmds.c | 10 ++-
src/backend/commands/vacuum.c | 30 ++++++--
src/backend/executor/execUtils.c | 3 +
src/backend/optimizer/util/plancat.c | 5 +-
src/backend/utils/cache/relcache.c | 20 +++++-
src/include/catalog/index.h | 9 ++
src/include/catalog/pg_index.h | 8 ++
11 files changed, 207 insertions(+), 76 deletions(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2012-11-29 20:33:59 | Re: Overlength socket paths (was Re: [COMMITTERS] pgsql: Refactor flex and bison make rules) |
Previous Message | Tom Lane | 2012-11-29 16:31:30 | Overlength socket paths (was Re: [COMMITTERS] pgsql: Refactor flex and bison make rules) |