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 1lNNfy-0000ev-4p for pgsql-bugs@arkaria.postgresql.org; Fri, 19 Mar 2021 22:33:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lNNfv-0002XG-JA for pgsql-bugs@arkaria.postgresql.org; Fri, 19 Mar 2021 22:32:59 +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 1lNNfu-0002X7-9O for pgsql-bugs@lists.postgresql.org; Fri, 19 Mar 2021 22:32:59 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lNNfp-0006Vj-1m for pgsql-bugs@lists.postgresql.org; Fri, 19 Mar 2021 22:32:57 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id DBF515C00C9; Fri, 19 Mar 2021 18:32:50 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Fri, 19 Mar 2021 18:32:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm1; bh=Jdb52lPuXjpXjJibitI4LwL6REs 8SB7AlyYIn0G73oA=; b=DQfJg1hlO5rbvHorEk7BUrDFIsHX96bVU0SxZBwYxY8 LjT8O0IrXiaA3x3SxxPSPY5higsR7fsHu/V8I0fLQzC5yqa5j0e+6weFhQXRAj22 qcpP3c/O6d4y9kQe3NjGjvFmqs52afDpbks2I7PAEnLcVD1o8ZuaoNnzen+iUrg6 Doy+fiJD0ZP8jGnTQ6c4LXwq4QDM0jGvAugvqY98pNRWLEAe4hYy5h2tdiInE1nh cHJKZhyCV4VDgyhNRK4hfZDPs6a27FQxYMfE4oZuo32WkIYzAJYf/tJNdGaF9EzZ IBp5AJjrAfC3U33FFXz1ZNzA9051Esm1yHm90HiVclw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=Jdb52l PuXjpXjJibitI4LwL6REs8SB7AlyYIn0G73oA=; b=wUyEBbyByNh+rMiZVmo1Va TA/WGnEE7i/SRFz0rUniFkFziW5PAuG/UqEh/3i2goplkjzcVVCxP5Bc0uTVAKw7 b5nwy8J1toBLjQAHzDAKCre6bMtcot7pnmwdKZwjQZC8lak/Y+IckGIfZgKahRAD XOyoC1ZlN/+BA1B/6EZ2nmnOazbuRD1RGBXkwyTabmW6FodisIGOgWr9RGUGLbQw KB+nj2szNsJvB5eZCyGjkBXNB71GTeMSRxjwNOjVO+pN3WWA0rDnedaQVM3Mb4Cl Ze1VmLdJa4sYw/t90zYTlyJ5D+pHkzXhpqCi/cVAHvbF9y3keV25cfET2MT6Fl6Q == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudefledgvdejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne gfrhhlucfvnfffucdlfeehmdenucfjughrpeffhffvuffkfhggtggujgesghdtreertddt vdenucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgvrhcuoehmihgthhgrvghlsehprg hquhhivghrrdighiiiqeenucggtffrrghtthgvrhhnpedvgeduuefhtdeuleettdevjeeh heeiveeuieegleetgeeljeelieeuieehgeevhfenucfkphepudduuddruddtvddrudektd drudekheenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhm pehmihgthhgrvghlsehprghquhhivghrrdighiii X-ME-Proxy: Received: from paquier.xyz (ee0822lan1.rev.em-net.ne.jp [111.102.180.185]) by mail.messagingengine.com (Postfix) with ESMTPA id 1FDE51080063; Fri, 19 Mar 2021 18:32:47 -0400 (EDT) Date: Sat, 20 Mar 2021 07:32:43 +0900 From: Michael Paquier To: Magnus Hagander Cc: Tom Lane , =?utf-8?B?0K/RgNC+0YHQu9Cw0LIg0J/QsNGI0LjQvdGB0LrQuNC5?= , Postgres bugs Subject: Re: BUG #16927: Postgres can`t access WAL files Message-ID: References: <4065519.1616166832@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="dsOAZ2Tqn+6oU6jh" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --dsOAZ2Tqn+6oU6jh Content-Type: multipart/mixed; boundary="sfeWsZ5gKWiB1x63" Content-Disposition: inline --sfeWsZ5gKWiB1x63 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Mar 19, 2021 at 04:19:50PM +0100, Magnus Hagander wrote: > On Fri, Mar 19, 2021 at 4:14 PM Tom Lane wrote: >> Given the evidence that there's a problem, I agree with reverting >> that. I'd suggest keeping the cosmetic rename of the function, >> but we have to put back the Windows-doesn't-HAVE_WORKING_LINK logic. >=20 > +1. I think the indications are definitely clear enough that this has > to go back in. No problem from me to keep the rename, and so this leads to the simple patch attached, then. Any comments? >> Grepping in the v12 branch, I find a second use of HAVE_WORKING_LINK >> in contrib/pg_standby. But that seems to be in a non-WIN32 code path, >> so I don't think putting that back is necessary. >=20 > .. and apart front aht I *really* doubt that one has many users, > especially on Windows :) Yeah, agreed. -- Michael --sfeWsZ5gKWiB1x63 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="win32-link.patch" Content-Transfer-Encoding: quoted-printable diff --git a/src/include/pg_config_manual.h b/src/include/pg_config_manual.h index f10ad0acd6..e28c990382 100644 --- a/src/include/pg_config_manual.h +++ b/src/include/pg_config_manual.h @@ -135,6 +135,13 @@ #define EXEC_BACKEND #endif =20 +/* + * Define this if your operating system supports link() + */ +#if !defined(WIN32) && !defined(__CYGWIN__) +#define HAVE_WORKING_LINK 1 +#endif + /* * USE_POSIX_FADVISE controls whether Postgres will attempt to use the * posix_fadvise() kernel call. Usually the automatic configure tests are diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c index 110ba31517..92b1959648 100644 --- a/src/backend/storage/file/fd.c +++ b/src/backend/storage/file/fd.c @@ -820,6 +820,7 @@ durable_rename_excl(const char *oldfile, const char *ne= wfile, int elevel) if (fsync_fname_ext(oldfile, false, false, elevel) !=3D 0) return -1; =20 +#ifdef HAVE_WORKING_LINK if (link(oldfile, newfile) < 0) { ereport(elevel, @@ -829,6 +830,17 @@ durable_rename_excl(const char *oldfile, const char *n= ewfile, int elevel) return -1; } unlink(oldfile); +#else + /* XXX: Add racy file existence check? */ + if (rename(oldfile, newfile) < 0) + { + ereport(elevel, + (errcode_for_file_access(), + errmsg("could not rename file \"%s\" to \"%s\": %m", + oldfile, newfile))); + return -1; + } +#endif =20 /* * Make change persistent in case of an OS crash, both the new entry and --sfeWsZ5gKWiB1x63-- --dsOAZ2Tqn+6oU6jh Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmBVJosACgkQnvQgOdby QH3arxAAp83CrNTRrAhj3YBqSazLn4IF5e740c0+GzmzVpt4JGPRCjIcFuYCcJb0 4LlK2QmOi4lcGEu1ivpwZzyrVBsT2SOJ5jJAGvISGo8e2tkeSnFUVuFZcxkYtVNy qvZQkqKl4SqnBVnp9HgKtjXRtDyy1vOK9WvNg2zoEOaMTgRVAY/XRDnhQBzsJt3v F1oq1Iz3a2fTwiTodu/ILnq13W5NsSFTglTXdMIDPqN1phbE3sdpPK6cSpSpi+64 cVKsmv8mcgMx05T5gsehh6IRvjNShOL+gJuORtwscA/HZoOM3YIaPEURXZTDcve8 bmtU6b+Co81p1okBSGEyxOprFekpnSgf/9okBUp2fBw5aTqDbf5ZiQIZ55CyQnxS rf4R+/+XjCMFsURTU1p5t2vLS8AR+1T4cc4ZD1CA1SIVIzrdheD91odE1+aLG/Ig n98HJhHiUXQjNC+RvaXAgNkuNJPvUOlBq/4INFTkUGA0CydfYs9uATmKxVnc5ohf oxx6GFXy33ezRexGaaFqlODhwLVbt2gFv7C8kjqICCyLLK+BYikJ8DhE32XSqmiz MtrYT3qRrKI81CFza9Pd05m06hf86vX58tJqNhIAY/rsZFQJRh15gUnm5bHEaFps cpEMhNeSRNZVSemOUsQC1D3vzzOrMF+mE0RSHIW5zo0YjoBUliU= =lUDy -----END PGP SIGNATURE----- --dsOAZ2Tqn+6oU6jh--