From 9bd85f38e976cb2828bc18449e9a0a52354c723b Mon Sep 17 00:00:00 2001 From: Peter Geoghegan Date: Tue, 18 Aug 2026 23:12:44 -0400 Subject: [PATCH v1 1/2] Re-check GinPageIsLeaf() after relocking a GIN posting tree root. Author: Peter Geoghegan Discussion: https://postgr.es/m/CAH2-Wz=RBpJTQgvOxr6C=J04dExmFSt1E3F-r+cRTQ56hEotkg@mail.gmail.com Backpatch-through: 14 --- src/backend/access/gin/ginvacuum.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/backend/access/gin/ginvacuum.c b/src/backend/access/gin/ginvacuum.c index 040f21a92..292b26cbf 100644 --- a/src/backend/access/gin/ginvacuum.c +++ b/src/backend/access/gin/ginvacuum.c @@ -399,6 +399,16 @@ ginVacuumPostingTreeLeaves(GinVacuumState *gvs, BlockNumber blkno) { LockBuffer(buffer, GIN_UNLOCK); LockBuffer(buffer, GIN_EXCLUSIVE); + + if (!GinPageIsLeaf(page)) + { + /* + * The root page was a leaf page, but became an internal page + * while no lock was held. Unlock and reacquire a share lock. + */ + UnlockReleaseBuffer(buffer); + continue; + } break; } -- 2.53.0