Re: simplehash: preserve consistency in case of OOM

Поиск
Список
Период
Сортировка
От Andres Freund
Тема Re: simplehash: preserve consistency in case of OOM
Дата
Msg-id 20231117201334.eyb542qr5yk4gilq@awork3.anarazel.de
обсуждение исходный текст
Ответ на simplehash: preserve consistency in case of OOM  (Jeff Davis <pgsql@j-davis.com>)
Ответы Re: simplehash: preserve consistency in case of OOM  (Jeff Davis <pgsql@j-davis.com>)
Re: simplehash: preserve consistency in case of OOM  (Gurjeet Singh <gurjeet@singh.im>)
Список pgsql-hackers
Hi,

On 2023-11-17 10:42:54 -0800, Jeff Davis wrote:
> Right now, if allocation fails while growing a hashtable, it's left in
> an inconsistent state and can't be used again.

I'm not against allowing this - but I am curious, in which use cases is this
useful?


> @@ -446,10 +459,11 @@ SH_CREATE(MemoryContext ctx, uint32 nelements, void *private_data)
>      /* increase nelements by fillfactor, want to store nelements elements */
>      size = Min((double) SH_MAX_SIZE, ((double) nelements) / SH_FILLFACTOR);
>  
> -    SH_COMPUTE_PARAMETERS(tb, size);
> +    size = SH_COMPUTE_SIZE(size);
>  
> -    tb->data = (SH_ELEMENT_TYPE *) SH_ALLOCATE(tb, sizeof(SH_ELEMENT_TYPE) * tb->size);
> +    tb->data = (SH_ELEMENT_TYPE *) SH_ALLOCATE(tb, sizeof(SH_ELEMENT_TYPE) * size);
>  
> +    SH_UPDATE_PARAMETERS(tb, size);
>      return tb;
>  }

Maybe add a comment explaining why it's important to update parameters after
allocating?

Greetings,

Andres Freund



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

Предыдущее
От: Jeff Davis
Дата:
Сообщение: Re: should check collations when creating partitioned index
Следующее
От: Tom Lane
Дата:
Сообщение: Re: should check collations when creating partitioned index