pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alexander Korotkov <akorotkov@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Prevent deadlock in ginRedoDeletePage()
Date: Thu, 13 Dec 2018 03:56:34 +0000
Message-ID: <E1gXI70-0005UH-Qx@gemulon.postgresql.org> (raw)

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
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/c6ade7a8cd3135af0c5d29abf39a6a83b9f6a66a

Modified Files
--------------
src/backend/access/gin/ginxlog.c | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)



view thread (6+ messages)

Message-ID: <E1gXI70-0005UH-Qx@gemulon.postgresql.org>
Permalink:  ../E1gXI70-0005UH-Qx@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1gXI70-0005UH-Qx@gemulon.postgresql.org

 · 

reply

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: Prevent deadlock in ginRedoDeletePage()
  In-Reply-To: <E1gXI70-0005UH-Qx@gemulon.postgresql.org>
  References: <E1gXI70-0005UH-Qx@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