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 1kEw4V-0003Mj-11 for pgsql-hackers@arkaria.postgresql.org; Sun, 06 Sep 2020 14:55:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kEw3x-0001L3-Fv for pgsql-hackers@arkaria.postgresql.org; Sun, 06 Sep 2020 14:54:37 +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 1kEw3x-0001Kv-4n for pgsql-hackers@lists.postgresql.org; Sun, 06 Sep 2020 14:54:37 +0000 Received: from lahtoruutu.iki.fi ([185.185.170.37]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kEw3p-0003IV-BC for pgsql-hackers@lists.postgresql.org; Sun, 06 Sep 2020 14:54:35 +0000 Received: from [192.168.1.113] (dsl-hkibng22-54faa4-119.dhcp.inet.fi [84.250.164.119]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: hlinnaka) by lahtoruutu.iki.fi (Postfix) with ESMTPSA id C3ABC1B00193; Sun, 6 Sep 2020 17:54:22 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1599404063; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yRIsX6L5CibKVr0IprQmJji2li2vHhowO7OK3kT/aP4=; b=d1vsRjuSAX8MCKOwoOfK/9k1OQZkGVRMVDr4h7BOZTC1ADz2wagwt1dfxerT9kgqhr/4S7 fl609H5desyqNH+zcFO4BV3o/+pehc8uM7r2ea5ugl8XNPFhj1Lz4rYvqNw8j58TNlwh+X bLySLPZhslm0KHA/EYmEF+qr6cIHnwShqFv4hA773Ed/h8BGPqq19qPCXl3RP/8Da+SbGv kAFVVs1gjB8y47N0Ad/sWQrCyQ+aK1TBWO+CFlgPP84tVlwOnAblDPPVlsx5lVdlFVu6l0 6WWehdoog8ZTWdmJlJyeJGtIe6L1zUoics7xTgJi8/MsEH2qIyz4oEIhHZnhAQ== Subject: Re: Dubious code in pg_rewind's process_target_file() To: Tom Lane , pgsql-hackers@lists.postgresql.org References: <1221796.1599329320@sss.pgh.pa.us> <1222282.1599329909@sss.pgh.pa.us> From: Heikki Linnakangas Message-ID: <6ba44dc9-2b7e-1988-de4e-99832235eae5@iki.fi> Date: Sun, 6 Sep 2020 17:54:22 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: <1222282.1599329909@sss.pgh.pa.us> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1599404063; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yRIsX6L5CibKVr0IprQmJji2li2vHhowO7OK3kT/aP4=; b=RgiP19l8jE87PkWqXc/2hjFw46IU4nLEG0/R6qK3QivSmrzCskDUv7E0YGnhyLvsaCE1b6 oTq8GVE8IbX/C/U1TPrcaeySd0PSIn68Aa2j4AniMIJN+rj1c10/F88Nx+KU7Qz1habxEt 1VJByskw3VmalsUqmXL7Vgv3UfjGCHRofivJgMsO1bx6mxCOYq5X2CHZ3OjDWs3bFfGf/8 2toQ8XdlJgyrBCPAqc1IHgy2n8glXMrmFR0I19jE5MqABmwtgLKJAejf3VSsHeKZGZhl8S AFOVr6c6p1jIZhgkUSxCA4JExWDsWCCFk6I7R68Lf/kyJlqV85fV0HFhCs4bnA== ARC-Seal: i=1; s=lahtoruutu; d=iki.fi; t=1599404063; a=rsa-sha256; cv=none; b=rSjQH0Z9A5s5WWHZZL0jcnkqZeL9IQKhkHbmk3A8pt97+J8603YAXjXm+I+pxT0MGEn48M SBfRxOVnEOBYoaT0dKjRwBpYmHF2Xve/yq8l36HgUch61c8NQbyE5VhA/wgAHvLeX4dt2q VCCMlo5qDGL4uApTMJOigfdF14z21isjF5VLil3ruXNMXntJRGhqRBFPwHmkYxM+coE7xJ t282wvIEaM+G1qXXOcbMnQ90tKmXA8TxKz+43WT5B3kp+mLfIDjrYt+jrh6las1pNpBnbW SgA/7DNS0fpvwJvAQx0gnulx80c1zKcmKSNCvWbvJYUsm5Otrwli0hCAbSEG7Q== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=hlinnaka smtp.mailfrom=hlinnaka@iki.fi List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 05/09/2020 21:18, Tom Lane wrote: > 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. Agreed, the lstat() doesn't do anything interesting. This is refactored away by the patches discussed at https://www.postgresql.org/message-id/f155aab5-1323-8d0c-9e3b-32703124bf00%40iki.fi. But maybe we should still clean it up in the back-branches. - Heikki