]> granicus.if.org Git - postgresql/commit
Avoid palloc in critical section in GiST WAL-logging.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Thu, 3 Apr 2014 12:09:37 +0000 (15:09 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Thu, 3 Apr 2014 12:44:42 +0000 (15:44 +0300)
commit767fc1c520a19f353006a5926cfea63bc4a4a57b
tree5f2b0f87c3612a66b335eaa8bea399083c66360c
parent65183fb78f1a31b6f333fde3293e047898bd6931
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.
src/backend/access/gist/README
src/backend/access/gist/gist.c
src/backend/access/gist/gistxlog.c
src/include/access/gist_private.h