From: | Alexander Korotkov <akorotkov(at)postgresql(dot)org> |
---|---|
To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
Subject: | pgsql: Prevent deadlock in ginRedoDeletePage() |
Date: | 2018-12-13 03:55:28 |
Message-ID: | E1gXI5w-0005Me-8X@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
Prevent deadlock in ginRedoDeletePage()
On standby ginRedoDeletePage() can work concurrently with read-only queries.
Those queries can traverse posting tree in two ways.
1) Using rightlinks by ginStepRight(), which locks the next page before
unlocking its left sibling.
2) Using downlinks by ginFindLeafPage(), which locks at most one page at time.
Original lock order was: page, parent, left sibling. That lock order can
deadlock with ginStepRight(). In order to prevent deadlock this commit changes
lock order to: left sibling, page, parent. Note, that position of parent in
locking order seems insignificant, because we only lock one page at time while
traversing downlinks.
Reported-by: Chen Huajun
Diagnosed-by: Chen Huajun, Peter Geoghegan, Andrey Borodin
Discussion: https://postgr.es/m/31a702a.14dd.166c1366ac1.Coremail.chjischj%40163.com
Author: Alexander Korotkov
Backpatch-through: 9.4
Branch
------
REL_11_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/225b5c9c480fa90d4734ce4a8d1a4b46ac5e826e
Modified Files
--------------
src/backend/access/gin/ginxlog.c | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Alexander Korotkov | 2018-12-13 03:56:01 | pgsql: Prevent deadlock in ginRedoDeletePage() |
Previous Message | Tom Lane | 2018-12-12 21:08:43 | pgsql: Repair bogus EPQ plans generated for postgres_fdw foreign joins. |