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 1gEiWT-0005SN-DH for pgsql-hackers@arkaria.postgresql.org; Mon, 22 Oct 2018 22:18:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gEiUJ-0005xK-6t for pgsql-hackers@arkaria.postgresql.org; Mon, 22 Oct 2018 22:15:51 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gEiUI-0005xD-Rm for pgsql-hackers@lists.postgresql.org; Mon, 22 Oct 2018 22:15:51 +0000 Received: from mail-qt1-x82c.google.com ([2607:f8b0:4864:20::82c]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gEiUB-0005by-8C for pgsql-hackers@lists.postgresql.org; Mon, 22 Oct 2018 22:15:50 +0000 Received: by mail-qt1-x82c.google.com with SMTP id g10-v6so7673431qtq.6 for ; Mon, 22 Oct 2018 15:15:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=XllsKZHDoRO3xSCG9SHV3InqyI8Op620W3fQffZVArs=; b=Vn8tyYpTbvHz4Z/7g7qDKQ+g9x3/u/NKtEl7js6IYCQu5r7ApGpOp7sYAmBvuz8gjp Zhf3AT/8WBdcUIBf1L5ZYtWvpXjl4R/WbrVtvOMlBxs4P4QZWJTS/w6rpLOcD6oIglPW CjfIC+YVsSoPfjCWDCALgwIOMHJrDQhSKyThN3OGLnlZa8SIwqmUc139QBjpiVNAJ/5h k0NhESVoNzbFuyQM+UupASoWSyq2Y3KqOGZWmdcNbkEGK7T1p4noqWd27SZBhe6F8UIN 2jsl6mA1cHWeZ+H4DA630lt4giJ5Yz2uJ5mYSBHbcbbvVo9YeBoy2Iez3H7qpf6FihSh sDTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=XllsKZHDoRO3xSCG9SHV3InqyI8Op620W3fQffZVArs=; b=oG2ePHcdT3PvvMMWwI70/Z6RBi2n0rT5AblY1OMV+TUlufvUqEZgzNgVBPcyEsmwYz 7c29bYoBMU/BufnLpzuMSoNfit/w70uNyT0jQlIs6GKyq2owBtHFMF66twY+CBvvjT13 XVxioV8gNS5OB0qQ6oKrEGhFJReEusIfX5FTzCc3OwyhuHX+aUNge6QPHSMWKv33I95d jfcvR53bJKdzriXQc9OEzZjT5r9R/fOOyf2ovI0CqZOM2P1Ek7p4NCe1gDR0jIV5sLm2 amDj7FtCadp+39F8rA0WRrLHd3qkA6flLK+TY3cR9enAj6j9lqPY+s55UM004lkI26X+ f5eA== X-Gm-Message-State: AGRZ1gKH/D4TiH/XSZmJogUXZjQ6N+spX6Y1QaDKh2OcqA7ny10Pp17N EnikLBiZU+PUULVRWxa8bBwyUQ== X-Google-Smtp-Source: ACcGV60Kzi1stZIPOtn9MAHRBuDMJ0NyzNP7q04Hqp78DS2YKkPzd54Z1y2UXBGhXFOyqM8cpQhGSQ== X-Received: by 2002:ac8:1e95:: with SMTP id c21-v6mr1831332qtm.167.1540246540970; Mon, 22 Oct 2018 15:15:40 -0700 (PDT) Received: from alvin.alvh.no-ip.org ([190.121.29.3]) by smtp.gmail.com with ESMTPSA id i65sm5932984qkh.49.2018.10.22.15.15.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Oct 2018 15:15:40 -0700 (PDT) Received: by alvin.alvh.no-ip.org (Postfix, from userid 1000) id 57D24640; Mon, 22 Oct 2018 19:15:38 -0300 (-03) Date: Mon, 22 Oct 2018 19:15:38 -0300 From: Alvaro Herrera To: Andres Freund Cc: Michael Paquier , pgsql-hackers@lists.postgresql.org Subject: Re: pgsql: Avoid duplicate XIDs at recovery when building initial snapshot Message-ID: <20181022221538.d73yxdypbmmzmi2l@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20181022174155.wxxu2qt3bcrbrqy5@alap3.anarazel.de> User-Agent: NeoMutt/20180716 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2018-Oct-22, Andres Freund wrote: > Hi, > > On 2018-10-22 12:36:25 -0300, Alvaro Herrera wrote: > > On 2018-Oct-14, Andres Freund wrote: > > > > > On 2018-10-14 13:26:24 +0000, Michael Paquier wrote: > > > > Avoid duplicate XIDs at recovery when building initial snapshot > > > > > I'm unhappy this approach was taken over objections. Without a real > > > warning. Even leaving the crummyness aside, did you check other users > > > of XLOG_RUNNING_XACTS, e.g. logical decoding? > > > > Mumble. Is there a real problem here -- I mean, did this break logical > > decoding? Maybe we need some more tests to ensure this stuff works > > sanely for logical decoding. > > 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. 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 :-) > > FWIW and not directly related, I recently became aware (because of a > > customer question) that txid_current_snapshot() is oblivious of > > XLOG_RUNNING_XACTS in a standby. AFAICS it's not a really serious > > concern, but it was surprising. > > That's more fundamental than just XLOG_RUNNING_XACTS though, no? The > whole way running transactions (i.e. including those that are just > detected by looking at their xid) are handled in the known xids struct > and in snapshots seems incompatible with that, no? hmm ... as I recall, txid_current_snapshot also only considers xacts by xid, so read-only xacts are not considered -- seems to me that if you think of snapshots in a general way, you're right, but for whatever you want txid_current_snapshot for (and I don't quite remember what that is) then it's not really important. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services