From: Julien Rouhaud <julien.rouhaud@dalibo.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Cc: Marc Cousin <marc.cousin@dalibo.com>
Subject: Re: Memory leak in GIN index build
Date: Mon, 18 Apr 2016 17:53:34 +0200
Message-ID: <571502FE.1030200@dalibo.com> (raw)
In-Reply-To: <23849.1460989984@sss.pgh.pa.us>
References: <571276DD.5050303@dalibo.com>
<17456.1460832307@sss.pgh.pa.us>
<5712B509.7040403@dalibo.com>
<23849.1460989984@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>
On 18/04/2016 16:33, Tom Lane wrote:
>
> I poked at this over the weekend, and got more unhappy the more I poked.
> Aside from the memory leakage issue, there are multiple coding-rule
> violations besides the one you noted about scope of the critical sections.
> One example is that in the page-split path for an inner page, we modify
> the contents of childbuf long before getting into the critical section.
> The number of out-of-date comments was depressingly large as well.
>
> I ended up deciding that the most reasonable fix was along the lines of
> my first alternative above. In the attached draft patches, the
> "placeToPage" method is split into two methods, "beginPlaceToPage" and
> "execPlaceToPage", where the second method is what's supposed to happen
> inside the critical section for a non-page-splitting update. Nothing
> that's done inside beginPlaceToPage is critical.
>
> I've tested this to the extent of verifying that it passes make
> check-world and stops the memory leak in your test case, but it could use
> more eyeballs on it.
>
Thanks! I also started working on it but it was very far from being
complete (and already much more ugly...).
I couldn't find any problem in the patch.
I wonder if asserting being in a critical section would be valuable in
the *execPlaceToPage functions, or that (leaf->walinfolen > 0) in
dataExecPlaceToPageLeaf(), since it's filled far from this function.
> Attached are draft patches against HEAD and 9.5 (they're the same except
> for BufferGetPage calls). I think we'd also want to back-patch to 9.4,
> but that will take considerable additional work because of the XLOG API
> rewrite that happened in 9.5. I also noted that some of the coding-rule
> violations seem to be new in 9.5, so the problems may be less severe in
> 9.4 --- the memory leak definitely exists there, though.
>
--
Julien Rouhaud
http://dalibo.com - http://dalibo.org
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: julien.rouhaud@dalibo.com, tgl@sss.pgh.pa.us, marc.cousin@dalibo.com
Subject: Re: Memory leak in GIN index build
In-Reply-To: <571502FE.1030200@dalibo.com>
References: <571276DD.5050303@dalibo.com> <17456.1460832307@sss.pgh.pa.us> <5712B509.7040403@dalibo.com> <23849.1460989984@sss.pgh.pa.us> <571502FE.1030200@dalibo.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox