BRIN autosummarization may need a snapshot
authorÁlvaro Herrera <alvherre@kurilemu.de>
Tue, 4 Nov 2025 12:23:26 +0000 (13:23 +0100)
committerÁlvaro Herrera <alvherre@kurilemu.de>
Tue, 4 Nov 2025 12:23:26 +0000 (13:23 +0100)
commit6ef33c8051ddfcfff32e5c788e8e7e2f5b10669b
tree9e05c4d93a9a4a2cbc05199cfc8b2f636eb45152
parent9b61096074af936cb3a55611b21b8b545f56cc1a
BRIN autosummarization may need a snapshot

It's possible to define BRIN indexes on functions that require a
snapshot to run, but the autosummarization feature introduced by commit
7526e10224f0 fails to provide one.  This causes autovacuum to leave a
BRIN placeholder tuple behind after a failed work-item execution, making
such indexes less efficient.  Repair by obtaining a snapshot prior to
running the task, and add a test to verify this behavior.

Author: Álvaro Herrera <alvherre@kurilemu.de>
Reported-by: Giovanni Fabris <giovanni.fabris@icon.it>
Reported-by: Arthur Nascimento <tureba@gmail.com>
Backpatch-through: 13
Discussion: https://postgr.es/m/202511031106.h4fwyuyui6fz@alvherre.pgsql
src/backend/postmaster/autovacuum.c
src/test/modules/brin/t/01_workitems.pl