Skip to content

Commit b3f919d

Browse files
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 9da0cc3), 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-
1 parent c1455de commit b3f919d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/backend/catalog/index.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -978,6 +978,12 @@ index_create(Relation heapRelation,
978978
!concurrent && !invalid,
979979
!concurrent);
980980

981+
/*
982+
* Register relcache invalidation on the indexes' heap relation, to
983+
* maintain consistency of its index list
984+
*/
985+
CacheInvalidateRelcache(heapRelation);
986+
981987
/* update pg_inherits, if needed */
982988
if (OidIsValid(parentIndexRelid))
983989
StoreSingleInheritance(indexRelationId, parentIndexRelid, 1);

0 commit comments

Comments
 (0)