Re: [HACKERS] hash_search and out of memory

2012-10-19 Thread Tom Lane
Hitoshi Harada writes: > OK. Looks better. But nentries should be bogus a little now? No, I think it's fine as is. Essentially this logic says "attempt to split when the new insertion would make us go over the target fill factor", whereas the old logic split when the just-completed insertion r

Re: [HACKERS] hash_search and out of memory

2012-10-19 Thread Hitoshi Harada
On Fri, Oct 19, 2012 at 11:40 AM, Tom Lane wrote: > Hitoshi Harada writes: >> On Thu, Oct 18, 2012 at 8:35 AM, Tom Lane 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 def

Re: [HACKERS] hash_search and out of memory

2012-10-19 Thread Tom Lane
Hitoshi Harada writes: > On Thu, Oct 18, 2012 at 8:35 AM, Tom Lane 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 >> expa

Re: [HACKERS] hash_search and out of memory

2012-10-18 Thread Hitoshi Harada
On Thu, Oct 18, 2012 at 8:35 AM, Tom Lane wrote: > I wrote: >> Hitoshi Harada writes: >>> If OOM happens during expand_table() in hash_search_with_hash_value() >>> for RelationCacheInsert, > > the palloc-based allocator does throw > errors. I think that when that was designed, we were thinking t

Re: [HACKERS] hash_search and out of memory

2012-10-18 Thread Tom Lane
I wrote: > Hitoshi Harada writes: >> If OOM happens during expand_table() in hash_search_with_hash_value() >> for RelationCacheInsert, > What OOM? expand_table is supposed to return without doing anything > if it can't expand the table. If that's not happening, that's a bug > in the hash code.

Re: [HACKERS] hash_search and out of memory

2012-10-18 Thread Tom Lane
Hitoshi Harada writes: > If OOM happens during expand_table() in hash_search_with_hash_value() > for RelationCacheInsert, What OOM? expand_table is supposed to return without doing anything if it can't expand the table. If that's not happening, that's a bug in the hash code.

[HACKERS] hash_search and out of memory

2012-10-17 Thread Hitoshi Harada
If OOM happens during expand_table() in hash_search_with_hash_value() for RelationCacheInsert, the hash table entry is allocated and stored in the hash table, but idhentry->reldesc remains NULL. Since OOM causes AbortTransaction(), in AtEOXact_RelationCache() this NULL pointer is referenced and we