Re: remaining sql/json patches

From: Amit Langote <amitlangote09(at)gmail(dot)com>
To: Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>
Cc: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Erik Rijkers <er(at)xs4all(dot)nl>, jian he <jian(dot)universality(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, Andrew Dunstan <andrew(at)dunslane(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: remaining sql/json patches
Date: 2024-03-07 07:26:08
Message-ID: CA+HiwqHXzxg8-raLpzCa7BYmYVUUFPOEZo3EVgCkcnXks9=vUQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Mar 6, 2024 at 1:07 PM Amit Langote <amitlangote09(at)gmail(dot)com> wrote:
> Hi Tomas,
>
> On Wed, Mar 6, 2024 at 6:30 AM Tomas Vondra
> <tomas(dot)vondra(at)enterprisedb(dot)com> wrote:
> > I'd say 2.5GB in ExecutorState seems a bit excessive ... Seems there's
> > some memory management issue? My guess is we're not releasing memory
> > allocated while parsing the JSON or building JSON output.
> >
> > I'm not attaching the data, but I can provide that if needed - it's
> > about 600MB compressed. The structure is not particularly complex, it's
> > movie info from [1] combined into a JSON document (one per movie).
>
> Thanks for the report.
>
> Yeah, I'd like to see the data to try to drill down into what's piling
> up in ExecutorState. I want to be sure of if the 1st, query functions
> patch, is not implicated in this, because I'd like to get that one out
> of the way sooner than later.

I tracked this memory-hogging down to a bug in the query functions
patch (0001) after all. The problem was with a query-lifetime cache
variable that was never set to point to the allocated memory. So a
struct was allocated and then not freed for every row where it should
have only been allocated once.

I've fixed that bug in the attached. I've also addressed some of
Jian's comments and made quite a few cleanups of my own.

Now I'll go look if Himanshu's concerns are a blocker for committing 0001. ;)

--
Thanks, Amit Langote

Attachment Content-Type Size
v42-0002-Show-function-name-in-TableFuncScan.patch application/octet-stream 22.6 KB
v42-0003-JSON_TABLE.patch application/octet-stream 187.2 KB
v42-0001-Add-SQL-JSON-query-functions.patch application/octet-stream 206.2 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2024-03-07 07:26:44 Re: Add new error_action COPY ON_ERROR "log"
Previous Message Michael Paquier 2024-03-07 07:24:26 Re: Add new error_action COPY ON_ERROR "log"