Revert changes in HOT handling of BRIN indexes
authorTomas Vondra <tomas.vondra@postgresql.org>
Thu, 16 Jun 2022 13:02:48 +0000 (15:02 +0200)
committerTomas Vondra <tomas.vondra@postgresql.org>
Thu, 16 Jun 2022 13:02:49 +0000 (15:02 +0200)
commite3fcca0d0d2414f3a50d6fd40eddf48b7df81475
tree6c1793031fd174af93149a23450e3e3b5299bdb4
parent664da2a389e5d1d4ebf0f98c82997739cd496e8e
Revert changes in HOT handling of BRIN indexes

This reverts commits 5753d4ee32 and fe60b67250 that modified HOT to
ignore BRIN indexes. The commit message for 5753d4ee32 claims that:

    When determining whether an index update may be skipped by using
    HOT, we can ignore attributes indexed only by BRIN indexes. There
    are no index pointers to individual tuples in BRIN, and the page
    range summary will be updated anyway as it relies on visibility
    info.

This is partially incorrect - it's true BRIN indexes don't point to
individual tuples, so HOT chains are not an issue, but the visibitlity
info is not sufficient to keep the index up to date. This can easily
result in corrupted indexes, as demonstrated in the hackers thread.

This does not mean relaxing the HOT restrictions for BRIN is a lost
cause, but it needs to handle the two aspects (allowing HOT chains and
updating the page range summaries) as separate. But that requires a
major changes, and it's too late for that in the current dev cycle.

Reported-by: Tomas Vondra
Discussion: https://postgr.es/m/05ebcb44-f383-86e3-4f31-0a97a55634cf@enterprisedb.com
17 files changed:
doc/src/sgml/indexam.sgml
src/backend/access/brin/brin.c
src/backend/access/gin/ginutil.c
src/backend/access/gist/gist.c
src/backend/access/hash/hash.c
src/backend/access/heap/heapam.c
src/backend/access/nbtree/nbtree.c
src/backend/access/spgist/spgutils.c
src/backend/utils/cache/relcache.c
src/include/access/amapi.h
src/include/utils/rel.h
src/include/utils/relcache.h
src/test/modules/dummy_index_am/dummy_index_am.c
src/test/regress/expected/brin.out
src/test/regress/expected/stats.out
src/test/regress/sql/brin.sql
src/test/regress/sql/stats.sql