Re: Bug in huge simplehash

Yura Sokolov <y.sokolov@postgrespro.ru>

From: Yura Sokolov <y.sokolov@postgrespro.ru>
To: Ranier Vilela <ranier.vf@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>, Andres Freund <andres@anarazel.de>, Tomas Vondra <tomas.vondra@2ndquadrant.com>
Date: 2021-08-10T12:10:49Z
Lists: pgsql-hackers

Attachments

Ranier Vilela писал 2021-08-10 14:21:
> Em ter., 10 de ago. de 2021 às 05:53, Yura Sokolov
> <y.sokolov@postgrespro.ru> escreveu:
> 
>> 
>> I went to check SH_GROW and.... It is `SH_GROW(SH_TYPE *tb, uint32
>> newsize)`
>> :-(((
>> Therefore when `tb->size == SH_MAX_SIZE/2` and we call `SH_GROW(tb,
>> tb->size * 2)`,
>> then SH_GROW(tb, 0) is called due to truncation.
>> And SH_COMPUTE_PARAMETERS is also accepts `uint32 newsize`.
>> 
>> Ahh... ok, patch is updated to fix this as well.
> 
> It seems that we need to fix the function prototype too.
> 
> /* void <prefix>_grow(<prefix>_hash *tb) */
> -SH_SCOPE void SH_GROW(SH_TYPE * tb, uint32 newsize); +SH_SCOPE void
> SH_GROW(SH_TYPE * tb, uint64 newsize);

Ahh... Thank you, Ranier.
Attached v2.

regards,

-----

Yura Sokolov

Commits

  1. Fix incorrect hash table resizing code in simplehash.h