HASH_FIXED_SIZE flag gets lost when attaching to existing hash table - Mailing list pgsql-hackers

From Aidar Imamov
Subject HASH_FIXED_SIZE flag gets lost when attaching to existing hash table
Date
Msg-id 4d0cb35ff01c5c74d2b9a582ecb73823@postgrespro.ru
Whole thread Raw
Responses Re: HASH_FIXED_SIZE flag gets lost when attaching to existing hash table
List pgsql-hackers
Hi hackers,

Recently, while working with hash tables in dynahash.c, I noticed 
something weird.
When a hash table is already created in shared memory, and the another 
process
calls hash_create attempting to attach to it, it seems like the 
HASH_FIXED_SIZE
flag gets lost.

For example, if you start the server compiled with the EXEC_BACKEND 
option, and a
hash table with a fixed size is created at the beginning in shared 
memory, any
other process started by the postmaster then tries to initialize its 
hash table
pointer by calling hash_create with HASH_ATTACH flag. But the table 
structure it
points to has 'isfixed' flag set to false, even though the original 
table was
created with a HASH_FIXED_SIZE provided.

This could lead to the situation where, when the table's capacity limit 
is reached
(which was specified when the table was created), the process will 
silently occupy
more of the shared memory (up to a certain point?). Then, another insert 
could
trigger an out of shared memory error.

Any thoughts?


Regards,
Aidar Imamov
Attachment

pgsql-hackers by date:

Previous
From: vignesh C
Date:
Subject: Re: Logical Replication of sequences
Next
From: Tomas Vondra
Date:
Subject: Re: PoC: adding CustomJoin, separate from CustomScan