Is element access after HASH_REMOVE ever OK?

Поиск
Список
Период
Сортировка
От Thomas Munro
Тема Is element access after HASH_REMOVE ever OK?
Дата
Msg-id CA+hUKGJ-ysnJFQJ5A67Gpj4g2Hu7W965qePF6+ReWMvn5j+Z6w@mail.gmail.com
обсуждение исходный текст
Ответы Re: Is element access after HASH_REMOVE ever OK?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Hi,

After hearing from a couple of directions about systems spending too
much time scanning the local lock hash table, I wrote the trivial
patch to put them in a linked list, before learning that people have
considered that before, so I should probably go and read some history
on that and find out why it hasn't been done...

However, I noticed in passing that RemoveLocalLock() accesses
*locallock after removing it from the hash table (in assertion builds
only).  So one question I have is whether it's actually a programming
rule that you can't do that (at most you can compare the pointer
against NULL), or whether it's supposed to be
safe-if-you-know-what-you're-doing, as the existing comments hints.
Here also is a patch that does wipe_mem on removed elements, as
threatened last time this topic came up[1], which reveals the problem.
I'm also not exactly sure why it's only a WARNING if your local lock
table is out of sync, but perhaps that's in the archives too.

[1]
https://www.postgresql.org/message-id/flat/CAHut%2BPs-pL%2B%2Bf6CJwPx2%2BvUqXuew%3DXt-9Bi-6kCyxn%2BFwi2M7w%40mail.gmail.com

Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Andres Freund
Дата:
Сообщение: Re: Reducing opr_sanity test's runtime under CLOBBER_CACHE_ALWAYS
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Is element access after HASH_REMOVE ever OK?