Re: fix a bogus line in dynahash.c - Mailing list pgsql-patches

From Qingqing Zhou
Subject Re: fix a bogus line in dynahash.c
Date
Msg-id d70q77$21aq$1@news.hub.org
Whole thread Raw
In response to fix a bogus line in dynahash.c  ("Qingqing Zhou" <zhouqq@cs.toronto.edu>)
List pgsql-patches
"Neil Conway" <neilc@samurai.com>writes
> Well, element_alloc() uses the hash table's alloc function pointer. In
> theory, that could be malloc() or anything else, although I notice this
> abstraction is not consistently maintained (e.g. dir_realloc assumes
> pfree() is sufficient to free an allocation).
>

Yes, in theory it could do so. But in fact element_alloc() uses
DynaHashAlloc() for ordinary hash table or uses ShmemAlloc() for shared
memory case. The problem is that both of these could elog(ERROR) themselves.

> I think it would be a good idea to change dynahash.c to assume that the
> hash table's allocation function will elog(ERROR) on out-of-memory,

DynaHashAlloc() looks like this. ShmemAlloc() just elog(WARNING), we could
revise it ... but if you do so, how to rewrite

if (!hash_search(HASH_ENTER))    /* for example: RememberFsyncRequest() */
    elog(FATAL/PANIC);

Use critical_section?

Regards,
Qingqing



pgsql-patches by date:

Previous
From: Neil Conway
Date:
Subject: Re: fix a bogus line in dynahash.c
Next
From: Tom Lane
Date:
Subject: Re: [PATCH] pg_autovacuum commandline password hiding.