Re: GIN amcheck leaks memory in gin_check_parent_keys_consistency

From: Ewan Young <kdbase(dot)hack(at)gmail(dot)com>
To: Kirill Reshke <reshkekirill(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: GIN amcheck leaks memory in gin_check_parent_keys_consistency
Date: 2026-07-03 06:08:24
Message-ID: CAON2xHMUGp_W2DorU3HM8Ky=4SZjXmYVkG8_4Dg6y9awNs4Baw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Kirill,.

On Fri, Jul 3, 2026 at 5:20 AM Kirill Reshke <reshkekirill(at)gmail(dot)com> wrote:
>
> I was debugging the GIN index issue today and noticed my postgresql
> session which I used to run amcheck eats too much memory. PFA fix.

Thanks for the patch — I reproduced the problem and confirm the fix works well.

prev_tuple is refreshed via CopyIndexTuple() each iteration but never freed, and
since the whole entry-tree traversal runs in one memory context, the copies pile
up (~one per entry-tree tuple) until the function returns. Your
pfree() fixes that.

One optional follow-up: the last prev_tuple of each page is still left behind
(reset to NULL on the next page, never freed in the while cleanup).

+1 from me.

>
>
>
> --
> Best regards,
> Kirill Reshke

--
Regards,
Ewan Young

In response to

Browse pgsql-hackers by date

  From Date Subject
Previous Message Amit Langote 2026-07-03 06:05:42 Re: Batching in executor