postgres.git / summary / log / commit / refs

commit    0a60a291c9a5b8ecdf44cbbfecc4504e3c21ef49
Author:   Peter Geoghegan <pg@bowt.ie>
Date:     Fri Aug 03 21:44:44 2018 +0000
First released in: 12.0, 9.3.24, 9.4.19, 9.5.14, 9.6.10, 10.5, 11.0

    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-


src/backend/catalog/index.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c index 5e7edd29fd0..22afdc0f90f 100644 --- a/src/backend/catalog/index.c +++ b/src/backend/catalog/index.c @@ -903,6 +903,12 @@ index_create(Relation heapRelation, !deferrable, !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. * [parent: 6faaf1b7303a]