hash_search and out of memory - Mailing list pgsql-hackers

From Hitoshi Harada
Subject hash_search and out of memory
Date
Msg-id CAP7QgmkonmeOGz=OUb1B1Ukv=oZhL3n2y3h7ibVAst+zdTUd5Q@mail.gmail.com
Whole thread Raw
Responses Re: hash_search and out of memory  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
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 hit SIGSEGV.

The fix would be either catch OOM error with PG_TRY() and undo the
hash entry, or do the expansion first and put the entry later.  The
latter is a bit ugly because we have to re-calculate hash bucket after
we decided to expand, so the former looks better.  Do you think of
other solutions?

Thanks,
-- 
Hitoshi Harada



pgsql-hackers by date:

Previous
From: Neil Tiffin
Date:
Subject: Re: Deprecating RULES
Next
From: Simon Riggs
Date:
Subject: Re: Bugs in planner's equivalence-class processing