public inbox for [email protected]
help / color / mirror / Atom feedFrom: Tomas Vondra <[email protected]>
To: David Rowley <[email protected]>
To: Tomas Vondra <[email protected]>
Cc: [email protected]
Subject: Re: pgsql: Improve accounting for memory used by shared hash tables
Date: Fri, 4 Apr 2025 04:58:10 +0200
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
<CAApHDvriCiNkm=v521AP6PKPfyWkJ++jqZ9eqX4cXnhxLv8w-A@mail.gmail.com>
<[email protected]>
<[email protected]>
On 4/4/25 02:41, Tomas Vondra wrote:
> On 4/4/25 01:43, Tomas Vondra wrote:
>> On 4/4/25 00:57, David Rowley wrote:
>>> On Thu, 3 Apr 2025 at 04:16, Tomas Vondra <[email protected]> wrote:
>>>> Improve accounting for memory used by shared hash tables
>>>
>>> I've not looked into why, but this is causing an issue in the
>>> join_rel_hash during add_join_rel(). See the attached script.
>>>
>>> ERROR: pfree called with invalid pointer 0x60a15edc44e0 (header
>>> 0x0000002000000008)
>>>
>>
>> Thanks for the report and reproducer. I'll take a look tomorrow.
>>
>
> I took a quick look, and I think the reason is fairly simple - the
> commit allocates the header and the directory as a single chunk. And for
> shared hash tables that's fine, because those have non-expandable
> directory. But the patch does the same thing for non-shared hash tables
> (not intentionally), which means that if we end up expanding the hash,
> it fails in dir_realloc(). Because hashp->dir is not a separately
> allocated chunk.
>
> This is clearly a bug in the patch, I should have caught this during a
> review. But I'm also quite surprised none of the regression tests seems
> to expand the hash table ...
>
> I'll think about a way to fix this tomorrow.
>
I ended up reverting this. Unfortunately, the patch assumed the
directory is pre-allocated and not expanding in more places. I wasn't
sure how long would it take me to fix this, or how invasive the fix
would be. It seems more appropriate to revert and then maybe apply a
reworked patch (not going to happen for PG18).
Thanks for the report, sorry for missing the issue in the first place.
--
Tomas Vondra
view thread (5+ messages)
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected]
Subject: Re: pgsql: Improve accounting for memory used by shared hash tables
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox