Re: hash_search and out of memory

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Hitoshi Harada <umi.tanuki@gmail.com>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2012-10-19T18:40:18Z
Lists: pgsql-hackers

Attachments

Hitoshi Harada <umi.tanuki@gmail.com> writes:
> On Thu, Oct 18, 2012 at 8:35 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> I'm not terribly comfortable with trying to use a PG_TRY block to catch
>> an OOM error - there are too many ways that could break, and this code
>> path is by definition not very testable.  I think moving up the
>> expand_table action is probably the best bet.  Will you submit a patch?

> Here it is. I factored out the bucket finding code to re-calculate it
> after expansion.

I didn't like that too much.  I think a better solution is just to do
the table expansion at the very start of the function, along the lines
of the attached patch.  This requires an extra test of the "action"
parameter, but I think that's probably cheaper than an extra function
call.  It's definitely cheaper than recalculating the hash etc when
a split does occur.

			regards, tom lane