]> granicus.if.org Git - postgresql/commit
Fix deadlock in GIN vacuum introduced by 218f51584d5
authorAlexander Korotkov <akorotkov@postgresql.org>
Thu, 13 Dec 2018 03:12:11 +0000 (06:12 +0300)
committerAlexander Korotkov <akorotkov@postgresql.org>
Thu, 13 Dec 2018 03:15:23 +0000 (06:15 +0300)
commit9aa94d8536f81168b6de3744c1fb4a173af1cefe
treedbd06cc2d458664c1c3fb33aeb762bc60e52ba2e
parent7465871879abdc43dad7b5f6dcf1dd4880d53f9e
Fix deadlock in GIN vacuum introduced by 218f51584d5

Before 218f51584d5 if posting tree page is about to be deleted, then the whole
posting tree is locked by LockBufferForCleanup() on root preventing all the
concurrent inserts.  218f51584d5 reduced locking to the subtree containing
page to be deleted.  However, due to concurrent parent split, inserter doesn't
always holds pins on all the pages constituting path from root to the target
leaf page.  That could cause a deadlock between GIN vacuum process and GIN
inserter.  And we didn't find non-invasive way to fix this.

This commit reverts VACUUM behavior to lock the whole posting tree before
delete any page.  However, we keep another useful change by 218f51584d5: the
tree is locked only if there are pages to be deleted.

Reported-by: Chen Huajun
Diagnosed-by: Chen Huajun, Andrey Borodin, Peter Geoghegan
Discussion: https://postgr.es/m/31a702a.14dd.166c1366ac1.Coremail.chjischj%40163.com
Author: Alexander Korotkov, based on ideas from Andrey Borodin and Peter Geoghegan
Reviewed-by: Andrey Borodin
Backpatch-through: 10
src/backend/access/gin/README
src/backend/access/gin/ginvacuum.c