]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix deadlock between ginDeletePage() and ginStepRight()
authorAlexander Korotkov <akorotkov@postgresql.org>
Tue, 19 Nov 2019 20:07:36 +0000 (23:07 +0300)
committerAlexander Korotkov <akorotkov@postgresql.org>
Tue, 19 Nov 2019 21:04:09 +0000 (00:04 +0300)
commite14641197a5690d92cc48446d0d40f1aec07bac7
tree1ae3b8c61f5a2d5fdd671263f0599a5086a0cdf1
parent5b805886ca11d5d74217ab1f12395ad54507d4d5
Fix deadlock between ginDeletePage() and ginStepRight()

When ginDeletePage() is about to delete page it locks its left sibling to revise
the rightlink.  So, it locks pages in right to left manner.  Int he same time
ginStepRight() locks pages in left to right manner, and that could cause a
deadlock.

This commit makes ginScanToDelete() keep exclusive lock on left siblings of
currently investigated path.  That elimites need to relock left sibling in
ginDeletePage().  Thus, deadlock with ginStepRight() can't happen anymore.

Reported-by: Chen Huajun
Discussion: https://postgr.es/m/5c332bd1.87b6.16d7c17aa98.Coremail.chjischj%40163.com
Author: Alexander Korotkov
Reviewed-by: Peter Geoghegan
Backpatch-through: 10
src/backend/access/gin/README
src/backend/access/gin/ginvacuum.c