aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Geoghegan <pg@bowt.ie>2018-08-03 14:44:56 -0700
committerPeter Geoghegan <pg@bowt.ie>2018-08-03 14:44:56 -0700
commitc83408aa71e06f60c30ffda103f513b7d52db05d (patch)
tree67d684934f194f5254eaa494b522a330c03e5cdf
parent2e838371b98bdda10368482af95758087badca05 (diff)
downloadpostgresql-c83408aa71e06f60c30ffda103f513b7d52db05d.tar.gz
postgresql-c83408aa71e06f60c30ffda103f513b7d52db05d.zip
Add table relcache invalidation to index builds.
It's necessary to make sure that owning tables have a relcache invalidation prior to advancing the command counter to make newly-entered catalog tuples for the index visible. inval.c must be able to maintain the consistency of the local caches in the event of transaction abort. There is usually only a problem when CREATE INDEX transactions abort, since there is a generic invalidation once we reach index_update_stats(). This bug is of long standing. Problems were made much more likely by the addition of parallel CREATE INDEX (commit 9da0cc35284), but it is strongly suspected that similar problems can be triggered without involving plan_create_index_workers(). (plan_create_index_workers() triggers a relcache build or rebuild, which previously only happened in rare edge cases.) Author: Peter Geoghegan Reported-By: Luca Ferrari Diagnosed-By: Andres Freund Reviewed-By: Andres Freund Discussion: https://postgr.es/m/CAKoxK+5fVodiCtMsXKV_1YAKXbzwSfp7DgDqUmcUAzeAhf=HEQ@mail.gmail.com Backpatch: 9.3-
-rw-r--r--src/backend/catalog/index.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index 2cf307de072..0591c084273 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -918,6 +918,12 @@ index_create(Relation heapRelation,
!concurrent);
/*
+ * Register relcache invalidation on the indexes' heap relation, to
+ * maintain consistency of its index list
+ */
+ CacheInvalidateRelcache(heapRelation);
+
+ /*
* Register constraint and dependencies for the index.
*
* If the index is from a CONSTRAINT clause, construct a pg_constraint