Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gEljk-0008Eh-Jt for pgsql-hackers@arkaria.postgresql.org; Tue, 23 Oct 2018 01:44:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gEljg-0004ND-Kt for pgsql-hackers@arkaria.postgresql.org; Tue, 23 Oct 2018 01:43:56 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gElje-0004N6-Sn for pgsql-hackers@lists.postgresql.org; Tue, 23 Oct 2018 01:43:56 +0000 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gEljV-0008Vx-Fn for pgsql-hackers@lists.postgresql.org; Tue, 23 Oct 2018 01:43:52 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id DA60CCE3; Mon, 22 Oct 2018 21:43:43 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Mon, 22 Oct 2018 21:43:44 -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=fm3; bh=D31Xxa+IRMws+Vvx9aqn5aPAX+Y 2EunRig7zxYYaydQ=; b=GeyJWuSUernaZ5JsNUqOm4VSv+q0FzhNUGnw+8ypACZ qJTmdB43szB5AvqQFNJ9+YKDeGOPji+eoH1CquLJp8CBti/3tAj7zRmK0Ug+oeg5 AQyLX4T8RLUPSY4On6wBMfg8cqLFDEAXYlk60wVytEoGc+fPcg9kPKT8XyHLq5fh jldXuuHRB5xukGViQ6oHukiISM61evuvMVNKv4Ij0DBszmGxJgvfS8t9jcPOXGtR 9E86SwNCtQhk7q/FjoLPqeyEBR9pXxTh5r3UdHWq50vWXrSLlA/rjSKTdDfMigBb xFD4wLer7MOIgH4JiAfELEJVS+28TAW9QxfzQ4t8Jbg== 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=fm1; bh=D31Xxa +IRMws+Vvx9aqn5aPAX+Y2EunRig7zxYYaydQ=; b=RNY8hkQE8/zvKjAisKfP/m /MKwJvmXbkaJV2ogL6NVZwNAY+szvyWeiWEYuf+O/eZQyRNCJNostQAYo0CZRP+U c/NfSvpT/unlU8s4bzB8wyrptf9vlmTapGixMzmOXzJ6fpYvHotwaZabH8uf2k++ gDYtAAh489CKz+rpP1H9ZQHNhF1plT6np3iMEJu0dfp5zi3mBDOu4v1FgHi4WLNM 8azZ41QmZQgxHDCywGGLhZWlxBwSEsJEbv8IGiJaWM3ZiQ/BlS609ugWYgbScqq3 jbbqR0Im3usfLWXpZEXinJKuMMmqlPMWcF8GWQcFMF+ihrPLoRnlF5cfVYTuSCiw == X-ME-Sender: X-ME-Proxy: Received: from paquier.xyz (c137162.net61215.cablenet.ne.jp [61.215.137.162]) by mail.messagingengine.com (Postfix) with ESMTPA id 96124E4240; Mon, 22 Oct 2018 21:43:41 -0400 (EDT) Date: Tue, 23 Oct 2018 10:43:38 +0900 From: Michael Paquier To: Alvaro Herrera Cc: Andres Freund , pgsql-hackers@lists.postgresql.org Subject: Re: pgsql: Avoid duplicate XIDs at recovery when building initial snapshot Message-ID: <20181023014338.GA1658@paquier.xyz> References: <20181022174155.wxxu2qt3bcrbrqy5@alap3.anarazel.de> <20181022221538.d73yxdypbmmzmi2l@alvherre.pgsql> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="bg08WKrSYDhXBjb5" Content-Disposition: inline In-Reply-To: <20181022221538.d73yxdypbmmzmi2l@alvherre.pgsql> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --bg08WKrSYDhXBjb5 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Oct 22, 2018 at 07:15:38PM -0300, Alvaro Herrera wrote: > On 2018-Oct-22, Andres Freund wrote: >> Hm? My point is that this fix just puts a band-aid onto *one* of the >> places that read a XLOG_RUNNING_XACTS. Which still leaves the contents >> of WAL record corrupted. There's not even a note at the WAL-record's >> definition or its logging denoting that the contents are not what you'd >> expect. I don't mean that the fix would break logical decoding, but >> that it's possible that an equivalent of the problem affecting hot >> standby also affects logical decoding. And even leaving those two users >> aside, it's possible that there will be further vulernable internal >> users or extensions parsing the WAL. >=20 > Ah! I misinterpreted what you were saying. I agree we shouldn't let > the WAL message have wrong data. Of course we shouldn't just add a > code comment stating that the data is wrong :-) Well, following the same kind of thoughts, txid_current_snapshot() uses sort_snapshot() to remove all the duplicates after fetching its data =66rom GetSnapshotData(), so wouldn't we want to do something about removal of duplicates if dummy PGXACT entries are found while scanning the ProcArray also in this case? What I would think we should do is not only to patch GetRunningTransactionData() but also GetSnapshotData() so as we don't have duplicates also in this case, and do things in such a way that both code paths use the same logic, and that we don't need to have sort_snapshot() anymore. That would be more costly though... -- Michael --bg08WKrSYDhXBjb5 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAlvOfMoACgkQnvQgOdby QH0jQQ/+OgMOARbFPxCTy8OTr/6N5NP/0tDd5ItVwyueCujfzLK3MUQxatC8SVO5 fp+3xren4TNd+EwyBNUbCUn3P706/N2GYwYEuS+xiO3rGGewyDU/gVFJsQD7Q1zH tU6yod4fHRi+kDAUp1ul/0QMzNffXxJdgYGvCLOG9kQsOlb7p2Kp4oYDu+aSJQx6 OqhgS5yi695TEV9XJk5IHbWjBBw39TsPwRRVkHhyxGk2g0MYoERhgSbZ8hGdv6Bh zaCGsN/ZKkPxZOKaGRPl1mTQxMbZ/GMB4cBwf5PVrR8+xqEM0VhJM9tmAzeBPL2C W/dUY9kwYfkn3yBZBVL0yJ9bG+ahmyShWxlLzSKHVu2k/v1dzf5N9FXJYSp9Qkvs QY1JzKxk6QYWFEqsMlZsT1S6e2+NJDEtliONRF0/x4hQK+L8/r2GyPqrWDAGFW77 vgib0csQtYbvGzUSWfYKi2q/lN9TEYFekl0GyTZGf3tlbOkIxWMGgJvfOlu/COhm +32mqarxk9yZ0nOou3xCfBYgQsN80gNiWrkkhS3pAWtfN7R6HNqYdLs6f8tanyMU VlOLPedcnXLp7QbbDu0kg2VMU8hutxZcp389cbfehFAg4IKaekhkqTDrmHTFmH+4 j/Cw3bCeHvRG4vBkv8SAr//HOscuLxSfgSO5INDDjg3vFIzHd2w= =Ahmw -----END PGP SIGNATURE----- --bg08WKrSYDhXBjb5--