Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kEcll-0005mU-SZ for pgsql-hackers@arkaria.postgresql.org; Sat, 05 Sep 2020 18:18:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kEclk-0005WU-Qt for pgsql-hackers@arkaria.postgresql.org; Sat, 05 Sep 2020 18:18:32 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kEclk-0005WN-EA for pgsql-hackers@lists.postgresql.org; Sat, 05 Sep 2020 18:18:32 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kEcli-0001Xb-AB for pgsql-hackers@lists.postgresql.org; Sat, 05 Sep 2020 18:18:31 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 085IITQo1222283 for ; Sat, 5 Sep 2020 14:18:29 -0400 From: Tom Lane To: pgsql-hackers@lists.postgresql.org Subject: Re: Dubious code in pg_rewind's process_target_file() In-reply-to: <1221796.1599329320@sss.pgh.pa.us> References: <1221796.1599329320@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Sat, 05 Sep 2020 14:08:40 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1222281.1599329909.1@sss.pgh.pa.us> Date: Sat, 05 Sep 2020 14:18:29 -0400 Message-ID: <1222282.1599329909@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk I wrote: > It looks to me like we could replace "exists = false" with "return", > rather than uselessly constructing a FILE_ACTION_REMOVE entry for > a file we've already proven is not there. Or actually, maybe we should just drop the lstat call altogether? AFAICS it's 99.99% redundant with the lstat that traverse_datadir has done nanoseconds before. Yeah, maybe somebody managed to drop the file in between, but the FILE_ACTION_REMOVE code would have to deal with such cases anyway in case a drop occurs later. regards, tom lane