hash_search and out of memory

From: Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: hash_search and out of memory
Date: 2012-10-18 05:42:45
Message-ID: CAP7QgmkonmeOGz=OUb1B1Ukv=oZhL3n2y3h7ibVAst+zdTUd5Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2012-10-18 06:25:57 Re: Bugs in planner's equivalence-class processing
Previous Message Neil Tiffin 2012-10-18 04:26:34 Re: Deprecating RULES