pgsql: On GiST page split, release the locks on child pages before recu

From: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: On GiST page split, release the locks on child pages before recu
Date: 2012-05-11 09:38:33
Message-ID: E1SSmIz-0002XV-CD@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

On GiST page split, release the locks on child pages before recursing up.

When inserting the downlinks for a split gist page, we used hold the locks
on the child pages until the insertion into the parent - and recursively its
parent if it had to be split too - were all completed. Change that so that
the locks on child pages are released after the insertion in the immediate
parent is done, before recursing further up the tree.

This reduces the number of lwlocks that are held simultaneously. Holding
many locks is bad for concurrency, and in extreme cases you can even hit
the limit of 100 simultaneously held lwlocks in a backend. If you're really
unlucky, you can hit the limit while in a critical section, which brings
down the whole system.

This fixes bug #6629 reported by Tom Forbes. Backpatch to 9.1. The page
splitting code was rewritten in 9.1, and the old code did not have this
problem.

Branch
------
REL9_1_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/153b1dbaa0b94143041ab1e0cf249a02380f0acf

Modified Files
--------------
src/backend/access/gist/gist.c | 123 ++++++++++++++++++++++++++++++----------
1 files changed, 93 insertions(+), 30 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Simon Riggs 2012-05-11 13:37:58 pgsql: Ensure age() returns a stable value rather than the latest value
Previous Message Tom Lane 2012-05-11 03:01:34 pgsql: Improve discussion of setting server parameters.