Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1asgh6-0002ky-9F for pgsql-hackers@arkaria.postgresql.org; Wed, 20 Apr 2016 01:12:40 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1asgh5-0007RC-IB for pgsql-hackers@arkaria.postgresql.org; Wed, 20 Apr 2016 01:12:39 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1asI8v-0000ZW-4A for pgsql-hackers@postgresql.org; Mon, 18 Apr 2016 22:59:45 +0000 Received: from mimolette.dalibo.net ([212.85.157.144] helo=mail.dalibo.com) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1asI8s-0007zv-5A for pgsql-hackers@postgresql.org; Mon, 18 Apr 2016 22:59:43 +0000 Received: from [192.168.37.2] (gev44-1-78-228-108-65.fbx.proxad.net [78.228.108.65]) by mail.dalibo.com (Postfix) with ESMTPSA id C8DC42C02DB; Tue, 19 Apr 2016 00:59:39 +0200 (CEST) Subject: Re: Memory leak in GIN index build To: Julien Rouhaud , Tom Lane 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> Cc: pgsql-hackers From: Marc Cousin Message-ID: <571566DB.8000108@dalibo.com> Date: Tue, 19 Apr 2016 00:59:39 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 MIME-Version: 1.0 In-Reply-To: <571502FE.1030200@dalibo.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org I had the possibility to perform tests on 9.5, and can confirm the memory leak I was seeing is solved with the patch (and that's great :) ) Regards Marc On 18/04/2016 17:53, Julien Rouhaud wrote: > 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. >> -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers