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 1krFO2-0003W4-Uj for pgsql-bugs@arkaria.postgresql.org; Mon, 21 Dec 2020 07:13:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1krFO1-0002XF-LB for pgsql-bugs@arkaria.postgresql.org; Mon, 21 Dec 2020 07:13:41 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1krFO0-0002X8-BS for pgsql-bugs@lists.postgresql.org; Mon, 21 Dec 2020 07:13:41 +0000 Received: from [64.147.123.25] (helo=wout2-smtp.messagingengine.com) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1krFNu-0002G0-VP for pgsql-bugs@lists.postgresql.org; Mon, 21 Dec 2020 07:13:40 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 3564363C; Mon, 21 Dec 2020 02:13:22 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Mon, 21 Dec 2020 02:13:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= date:from:to:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm3; bh=pmdnCXuknaSNR+MOX5K5g+pop2b WcqesPZg+HnI7wo0=; b=exP+/C3ZPHCtXjTl0CgZxvE2DNlQoRZbJM+1zEkz4XI 786i102UxB5yu+tzlSONO5xq8MANTBEZs8CHCLPBQg7FVkUBwApFUhaNpns45/r4 7uSCRZOLVXek+T+w8FMWoKDxSiOAyyh3kCOZ37T1B2xbkgExjbEPjqq4MNr3tf44 +OZFvtD/twcl86fT/DZ85fLsaMSPQtfzAbnWoUSQvAHvMJMXdH6pxiiaJVD47zqq 2vF17FspHeOEfS6QQKSar4f7bz2SdNfwz6LmtzWkZ5A5v9HuU5hI1aMXOJ12ga0K p88OfD6vz+atvrNMQo2kDNOVigi9LxdxhVicI5yb5Nw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=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=fm1; bh=pmdnCX uknaSNR+MOX5K5g+pop2bWcqesPZg+HnI7wo0=; b=WKOR2wL0FWDtCbuwPrPBR/ XWacINVUWijfP/1BQhSifBBY8bhdEJ83f6ZaS3jQpTzbTWKkYGKdEwTJ2qC8ueis Cl+xHeR/LQStBZuX/tT7FMcr/HS6SPzdIEetIWnWyd07/2vhrqEIJDrgreZ7f5u5 8Dsr0xFuD5FGGxpkA6iLzfcI9dpR7jtfVJC8mDnwo36Ibmk6bFDPd+Y05GCz5FeE KtvEa+XiCkpaDynF4OU+gx98LmItt+vvGkq4uBj8kqJowVgco+5tqNgmlnEEMjKM YVm6kpgilerKzJiHMXPRsjh1BKuAgj4rddZJFs4TMWL7LqQysli7KoKee5I60TxA == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrvddtuddguddtjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecufghrlhcuvffnffculdejtddmnecujfgurhepff fhvffukfhfgggtuggjsehgtderredttddvnecuhfhrohhmpefoihgthhgrvghlucfrrghq uhhivghruceomhhitghhrggvlhesphgrqhhuihgvrhdrgiihiieqnecuggftrfgrthhtvg hrnhepvdegudeuhfdtueeltedtveejheehieevueeigeelteegleejleeiueeiheegvefh necukfhppeduuddurddutddvrddukedtrddukeehnecuvehluhhsthgvrhfuihiivgeptd enucfrrghrrghmpehmrghilhhfrhhomhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiih ii 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 934B3108005C; Mon, 21 Dec 2020 02:13:20 -0500 (EST) Date: Mon, 21 Dec 2020 16:13:17 +0900 From: Michael Paquier To: exclusion@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #16780: Inconsistent recovery_target_xid handling across platforms Message-ID: References: <16780-107fd0c0385b1035@postgresql.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="Ml+e4hRXXwlAbGdD" Content-Disposition: inline In-Reply-To: <16780-107fd0c0385b1035@postgresql.org> X-Host-Lookup-Failed: Reverse DNS lookup failed for 64.147.123.25 (deferred) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --Ml+e4hRXXwlAbGdD Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, Dec 18, 2020 at 10:00:00AM +0000, PG Bug reporting form wrote: > So on Windows the recovery_target_xid parameter doesn't accept 64-bit > value. > As I see in check_recovery_target_xid() the strtoul() function is used to > check/convert the input value, that is later stored into 32-bit variable. > Thus, on platforms where unsigned long is 32-bit wide, you can't specify a > result of pg_current_xact_id() as recovery_target_xid, while on platforms > where unsigned long is 64-bit, you can, but high 32 bits are just ignored. In order to make the experience consistent across all platforms, we can use pg_strtouint64() for the GUC parsing. I agree that ignoring the high bits can be confusing as recovery would stop once a XID matches with a modulo of UINT32_MAX, but beginning to issue an error on platforms where unsigned long is 8 bytes could also break existing tools. At the same time, WAL record headers and 2PC state data only use 32-bit XIDs, so ignoring the high bits changes nothing at recovery (XIDs don't go across more than one epoch in the WAL stream AFAIK). In short, I agree that there is room for improvement here and that we should just allow the case to work by replacing the use of strtoul() to pg_strtouint64(). I am ready to bet that a lot of users setting a target XID rely on the return result of txid_current() or pg_current_xact_id() similarly to the test failing here. And once the epoch increments, the problems begin. Thoughts? -- Michael --Ml+e4hRXXwlAbGdD Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAl/gSwwACgkQnvQgOdby QH23RxAAktQNz5Pm7rOdt/Q+XZVEyigYAuDrJPye3VUSmVBZbb/6EWeG7qXMnjFm q8rMGL+CYHkcd4n8VAajUUNOwTfWmXyTV22uQdaIgnxe9Xw8Kv1fB52aAc5o9v4e ul+SgfbsOD/t/OfjkU21ofhiLTreTA4hinZY8vcQNR0WHBWsH54Gn0pWV7pgpCoT jAxccnnFXT4F1BAjbSioCjrZsj8p7IpJPnz12aGAVTxz7ynkqWkc1qIBbCGOOyHp a4GeuIHxsb9QW41phZS9IZqEPWfUO9OeSRRrte10gwic6h6lmTUSUdJ7DzbVIDYJ ykwBeF4zQVZx1sqg7jZqAEATR/vhThd+BLD+nQ6lrRalkr5e6ToraSIou8bmZXt0 ZTNJPDQ8Yr2mCCKT4syu2ZJxThU1nPbMyb3Vf7TrYQ4/1JjRnAnBpVITnQrzYZmX gK/tUXEn6uWGKFHHP7ukEq+44XXRgZwy+VL+ByyPdWWts3jxy7wZziSn/tP6v6jY IeiqD7lqikix4uL2KtfhnkGdCEr1LO5nD8e1V7Q0WSYr2CZl0fdN2yYcUTKOay7l XKGw8LkpGAU7K1Dbv2475Z1eleIkPktqhHt5nSghUHWh9HzA0LDqzlvAlv78d0en i3ys+Gq8EShpRtgQlNPWXMe+Ihe+Dm3V9LEUlddt6nAydpmsyAo= =WZFX -----END PGP SIGNATURE----- --Ml+e4hRXXwlAbGdD--