Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gcI5c-0000iU-Fb for pgsql-hackers@arkaria.postgresql.org; Wed, 26 Dec 2018 22:55:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gcI5a-0002o3-1c for pgsql-hackers@arkaria.postgresql.org; Wed, 26 Dec 2018 22:55:46 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gcI5Z-0002n2-0h for pgsql-hackers@lists.postgresql.org; Wed, 26 Dec 2018 22:55:45 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gcI5W-0000T4-FN for pgsql-hackers@postgresql.org; Wed, 26 Dec 2018 22:55:43 +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 wBQMtaxL026010; Wed, 26 Dec 2018 17:55:36 -0500 From: Tom Lane To: Michael Paquier cc: Postgres hackers , Peter Eisentraut Subject: Re: pgsql: Fix failure to check for open() or fsync() failures. In-reply-to: <20181226224351.GA2106@paquier.xyz> References: <20181226224351.GA2106@paquier.xyz> Comments: In-reply-to Michael Paquier message dated "Thu, 27 Dec 2018 07:43:51 +0900" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <26008.1545864936.1@sss.pgh.pa.us> Date: Wed, 26 Dec 2018 17:55:36 -0500 Message-ID: <26009.1545864936@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Michael Paquier writes: > On Wed, Dec 26, 2018 at 09:08:23PM +0000, Tom Lane wrote: >> Fix failure to check for open() or fsync() failures. >> >> While it seems OK to not be concerned about fsync() failure for a >> pre-existing signal file, it's not OK to not even check for open() >> failure. This at least causes complaints from static analyzers, > Wouldn't it be more simple to remove stat() and just call > BasicOpenFilePerm, complaining with FATAL about any failures, > including EACCES, on the way? The code is racy as designed, even if > that's not a big deal for recovery purposes. It appears to me that the code is intentionally not worrying about fsync failure, so it seems wrong for it to FATAL out if it's unable to open the file to fsync it. And it surely shouldn't do so if the file isn't there. regards, tom lane