Re: [HACKERS] unsafe use of hash_search(... HASH_ENTER ...)

2005-06-08 Thread Tom Lane
"Qingqing Zhou" <[EMAIL PROTECTED]> writes: > Yeah, you are right. I scratched elog/ereport(FATAL/PANIC), only found this > one might be a suspect: > In _hash_expandtable(): > if (!_hash_try_getlock(rel, start_nblkno, HASH_EXCLUSIVE)) > elog(PANIC, "could not get lock on supposedly new bucket

Re: [HACKERS] unsafe use of hash_search(... HASH_ENTER ...)

2005-06-08 Thread Qingqing Zhou
"Tom Lane" <[EMAIL PROTECTED]> writes > > This is not an issue except if the system might actually try to recover; > which is not the case in the postmaster snippet you mention. > Yeah, you are right. I scratched elog/ereport(FATAL/PANIC), only found this one might be a suspect: In _hash_expand

Re: [HACKERS] unsafe use of hash_search(... HASH_ENTER ...)

2005-06-05 Thread Tom Lane
"Qingqing Zhou" <[EMAIL PROTECTED]> writes: > I am afraid the problem are not limited to hash_search(). Any code snippet > are not proteced by critical section like this: This is not an issue except if the system might actually try to recover; which is not the case in the postmaster snippet you me

Re: [HACKERS] unsafe use of hash_search(... HASH_ENTER ...)

2005-06-05 Thread Qingqing Zhou
"Tom Lane" <[EMAIL PROTECTED]> writes > "Qingqing Zhou" <[EMAIL PROTECTED]> writes: > > In general, code snippet like this: > > > if (hash_search(..., HASH_ENTER, ...) == NULL) > > action_except_elog__ERROR__; > > > are considered unsafe if: (1) the allocation method of the target hash table >

Re: [HACKERS] unsafe use of hash_search(... HASH_ENTER ...)

2005-05-28 Thread Tom Lane
"Qingqing Zhou" <[EMAIL PROTECTED]> writes: > In general, code snippet like this: > if (hash_search(..., HASH_ENTER, ...) == NULL) > action_except_elog__ERROR__; > are considered unsafe if: (1) the allocation method of the target hash table > could elog(ERROR) themselves and (2) the reaction

Re: [HACKERS] unsafe use of hash_search(... HASH_ENTER ...)

2005-05-28 Thread Tom Lane
"Qingqing Zhou" <[EMAIL PROTECTED]> writes: > Consider the senario like this: > Backends register some dirty segments in BgWriterShmem->requests; bgwrite > will AbsorbFsyncRequests() asynchornously but failed to record some one in > pendingOpsTable due to an "out of memory" error. All dirty segmen

Re: [HACKERS] unsafe use of hash_search(... HASH_ENTER ...)

2005-05-26 Thread Qingqing Zhou
"Tom Lane" <[EMAIL PROTECTED]> writes > "Qingqing Zhou" <[EMAIL PROTECTED]> writes: > > "Unsafe" is a bit of an overstatement, when you evidently haven't > analyzed the consequences of either choice of error level. That is, > why is this a bug? > Consider the senario like this: Backends registe

Re: [HACKERS] unsafe use of hash_search(... HASH_ENTER ...)

2005-05-26 Thread Tom Lane
"Qingqing Zhou" <[EMAIL PROTECTED]> writes: > In md.c/RememberFsyncRequest(): > if (hash_search(pendingOpsTable, &entry, HASH_ENTER, NULL) == NULL) > ereport(FATAL, > (errcode(ERRCODE_OUT_OF_MEMORY), > errmsg("out of memory"))); > pendingOpsTable uses "MdCxt" to allocate memory. So if

[HACKERS] unsafe use of hash_search(... HASH_ENTER ...)

2005-05-26 Thread Qingqing Zhou
-- First part --- In md.c/RememberFsyncRequest(): if (hash_search(pendingOpsTable, &entry, HASH_ENTER, NULL) == NULL) ereport(FATAL, (errcode(ERRCODE_OUT_OF_MEMORY), errmsg("out of memory"))); pendingOpsTable uses "MdCxt" to allocate memory. So if "out of memory", we actually have no