Re: Clear padding in PgStat_HashKey keys
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Cc: pgsql-hackers@lists.postgresql.org
Date: 2024-11-04T07:25:00Z
Lists: pgsql-hackers
On Sun, Nov 03, 2024 at 04:25:41AM +0000, Bertrand Drouvot wrote:
> We are using sizeof(PgStat_HashKey) in pgstat_cmp_hash_key() and we compute the
> hash hash key in pgstat_hash_hash_key() using the PgStat_HashKey struct size as
> input: this lead to unexpected results if the keys contain random data in the
> padding bytes.
So you've seen that your patch was behaving weirdly once you have
added padding because the hash key size has been extended, leading to
relfilenode entries not being fetched when they should, right?
Perhaps it would be simpler to use a {0} like anywhere else for
PgStat_HashKey in pgstat_fetch_entry() and pgstat_drop_entry(), then
initialize the individual fields?
--
Michael
Commits
-
Clear padding of PgStat_HashKey when handling pgstats entries
- 6d5e6693ee6b 15.9 landed
- 925b3aa85700 16.5 landed
- 7f3b41ce48a5 17.1 landed
- 7d85d87f4d5c 18.0 landed