Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1euJT6-00066U-5v for pgsql-bugs@arkaria.postgresql.org; Fri, 09 Mar 2018 14:58:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1euJT5-0001cM-0m for pgsql-bugs@arkaria.postgresql.org; Fri, 09 Mar 2018 14:57:59 +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.89) (envelope-from ) id 1euJT4-0001cD-Nr for pgsql-bugs@lists.postgresql.org; Fri, 09 Mar 2018 14:57:58 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1euJT2-0005ro-1h for pgsql-bugs@lists.postgresql.org; Fri, 09 Mar 2018 14:57:57 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w29EvmcH019687; Fri, 9 Mar 2018 09:57:48 -0500 From: Tom Lane To: Michael Paquier cc: bianpan2016@163.com, pgsql-bugs@lists.postgresql.org, Robert Haas Subject: Re: BUG #15105: OpenTransientFile() should be paired with CloseTransientFile() rather than close() In-reply-to: <20180309044052.GC1416@paquier.xyz> References: <152056616579.4966.583293218357089052@wrigleys.postgresql.org> <20180309044052.GC1416@paquier.xyz> Comments: In-reply-to Michael Paquier message dated "Fri, 09 Mar 2018 13:40:52 +0900" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <19685.1520607468.1@sss.pgh.pa.us> Date: Fri, 09 Mar 2018 09:57:48 -0500 Message-ID: <19686.1520607468@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Michael Paquier writes: > On Fri, Mar 09, 2018 at 03:29:25AM +0000, PG Bug reporting form wrote: >> Details: The handler opened with OpenTransientFile() should be closed with >> CloseTransientFile(). However, in function dsm_impl_mmap(), on a certain >> path, the return value of OpenTransientFile() (at line 885) is passed to >> close() (at line 926). It is better to use CloseTransientFile() here, as >> done at line 909. > Good catch! This is visibly a copy-paste error coming from > dsm_impl_posix(). As a patch it gives the attached. I am adding also > Robert in CC for awareness. Presumably, this would have been found sooner if AtEOXact_Files acted like most other end-of-xact cleanup functions and whined about leaked resources (in the commit case). I wonder why it doesn't. regards, tom lane