]> granicus.if.org Git - postgresql/commit
Prevent GIN deleted pages from being reclaimed too early
authorAlexander Korotkov <akorotkov@postgresql.org>
Thu, 13 Dec 2018 03:12:31 +0000 (06:12 +0300)
committerAlexander Korotkov <akorotkov@postgresql.org>
Thu, 13 Dec 2018 03:41:04 +0000 (06:41 +0300)
commita0696d29551bf3cb5dbd2b72f89aed0bbf0dcab3
tree7c807f46754b3fccbc0d8b6321847837d4a3c76c
parent865870374aff35b886afac12e71542a1b079a021
Prevent GIN deleted pages from being reclaimed too early

When GIN vacuum deletes a posting tree page, it assumes that no concurrent
searchers can access it, thanks to ginStepRight() locking two pages at once.
However, since 9.4 searches can skip parts of posting trees descending from the
root.  That leads to the risk that page is deleted and reclaimed before
concurrent search can access it.

This commit prevents the risk of above by waiting for every transaction, which
might wait to reference this page, to finish.  Due to binary compatibility
we can't change GinPageOpaqueData to store corresponding transaction id.
Instead we reuse page header pd_prune_xid field, which is unused in index pages.

Discussion: https://postgr.es/m/31a702a.14dd.166c1366ac1.Coremail.chjischj%40163.com
Author: Andrey Borodin, Alexander Korotkov
Reviewed-by: Alexander Korotkov
Backpatch-through: 9.4
src/backend/access/gin/README
src/backend/access/gin/ginutil.c
src/backend/access/gin/ginvacuum.c
src/backend/access/gin/ginxlog.c
src/include/access/ginblock.h
src/include/access/ginxlog.h