From: Alexander Korotkov <akorotkov@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix deadlock between ginDeletePage() and ginStepRight()
Date: Tue, 19 Nov 2019 21:08:45 +0000
Message-ID: <E1iXAjt-0001cB-Gs@gemulon.postgresql.org> (raw)
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
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/e14641197a5690d92cc48446d0d40f1aec07bac7
Modified Files
--------------
src/backend/access/gin/README | 79 ++++++++++++++++++++++----------------
src/backend/access/gin/ginvacuum.c | 54 +++++++++++++++++---------
2 files changed, 81 insertions(+), 52 deletions(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: akorotkov@postgresql.org
Subject: Re: pgsql: Fix deadlock between ginDeletePage() and ginStepRight()
In-Reply-To: <E1iXAjt-0001cB-Gs@gemulon.postgresql.org>
References: <E1iXAjt-0001cB-Gs@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox