pgsql: Avoid palloc in critical section in GiST WAL-logging.

From: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Avoid palloc in critical section in GiST WAL-logging.
Date: 2014-04-03 12:57:03
Message-ID: E1WVhCZ-0003ST-JL@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Avoid palloc in critical section in GiST WAL-logging.

Memory allocation can fail if you run out of memory, and inside a critical
section that will lead to a PANIC. Use conservatively-sized arrays in stack
instead.

There was previously no explicit limit on the number of pages a GiST split
can produce, it was only limited by the number of LWLocks that can be held
simultaneously (100 at the moment). This patch adds an explicit limit of 75
pages. That should be plenty, a typical split shouldn't produce more than
2-3 page halves.

The bug has been there forever, but only backpatch down to 9.1. The code
was changed significantly in 9.1, and it doesn't seem worth the risk or
trouble to adapt this for 9.0 and 8.4.

Branch
------
REL9_3_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/767fc1c520a19f353006a5926cfea63bc4a4a57b

Modified Files
--------------
src/backend/access/gist/README | 2 +-
src/backend/access/gist/gist.c | 14 ++++++++++++++
src/backend/access/gist/gistxlog.c | 16 ++++++++--------
src/include/access/gist_private.h | 15 +++++++++++++++
4 files changed, 38 insertions(+), 9 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2014-04-03 15:06:58 pgsql: Fix documentation about size of interval type.
Previous Message Tom Lane 2014-04-02 21:11:57 pgsql: Fix assorted issues in client host name lookup.