Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cjThu-0007fn-LV for pgsql-hackers@arkaria.postgresql.org; Thu, 02 Mar 2017 16:35:58 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cjTht-00068v-Vs for pgsql-hackers@arkaria.postgresql.org; Thu, 02 Mar 2017 16:35:58 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cjTgP-0001Oh-5G for pgsql-hackers@postgresql.org; Thu, 02 Mar 2017 16:34:25 +0000 Received: from mail-wr0-x22b.google.com ([2a00:1450:400c:c0c::22b]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1cjTgL-0000Ju-Mg for pgsql-hackers@postgresql.org; Thu, 02 Mar 2017 16:34:23 +0000 Received: by mail-wr0-x22b.google.com with SMTP id g10so56418855wrg.2 for ; Thu, 02 Mar 2017 08:34:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=NeBYwgwNyrGbxQKvzYiK6DOqO6d3GNFblhtlFcRkqQM=; b=nyh8ujmaoLA/RQS0atIc6fXH3E6K3BnPSrBtGzPTiEvtfQg0fTF45gTyKlgvhTvvWM oIgi+JuyD9csZfK8zVj3ZCCPaIBTzXpqS/31EA4p2FwEwnviFwU34eeaxZ3iHweoScxi y9l5goRyk1pvZZXtoZjgln5JjsEl536nMSezA1TF5UDTwxVXHn+oafws7yszHJMU/efo 3hTnXLVL0NlnokGOumCc+ALvFU/vtfab6jNAwG1k1G/i98298Q+OFdXevREqtT4FxvfF NGgQhfea5jWkyJFBoJRjPU9FxdI4lz7qOfct9aBOD8Jmcxgtonw/CzTL+cydp5IXkG93 7prQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=NeBYwgwNyrGbxQKvzYiK6DOqO6d3GNFblhtlFcRkqQM=; b=c81TkM+FqsvJQRjVTbt23/HdrS9ypiHo6Uqs3HqWN16r3Ac1UGWsr45vEiz1GBlkDD 3vh9THS09/BNQuS/zNViRwEN6c48kg2sxZBuqRsJeFTXntU6NZanvyvFYmAcKtug4bGI SdjzfeZ2ALSCyF3RCQldhKINptrBEuf45WGFZmbe6waaWHF0zN63aDaB1/LEBTHwcCiH gU86Qf2EieEccyURo3oH2+F3KT5Mn6lslhkdsfueQniVEw5gN3W0BdnFQV7Yx6uCbi2j s9IMzCxph1aVyKzsv8C5YLx8O5Dl3HCoG59VJLF6+xD5heLOrBCVst1/Cn5LPkfn4H4C V17A== X-Gm-Message-State: AMke39kPPxOai/sSp2fXPxGyVp4wwgtT9+cYTrV5BjXWnpq6pLsOuu2qtucC6LDm96RP4u77 X-Received: by 10.223.165.6 with SMTP id i6mr506561wrb.18.1488472459944; Thu, 02 Mar 2017 08:34:19 -0800 (PST) Received: from [192.168.0.105] (150.123.broadband11.iol.cz. [90.178.123.150]) by smtp.gmail.com with ESMTPSA id w207sm27681879wmw.29.2017.03.02.08.34.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Mar 2017 08:34:19 -0800 (PST) Subject: Re: logical decoding of two-phase transactions To: Craig Ringer , Stas Kelvich References: <02DA5F5E-CECE-4D9C-8B4B-418077E2C010@postgrespro.ru> <89073436-925E-4299-A9AF-88D04E55C231@postgrespro.ru> <3477E635-F590-4432-BD20-C59142B65CD3@postgrespro.ru> <1FE466EA-7058-484D-B0DB-42CD81FA59F0@postgrespro.ru> <46ebc39d-82a0-e59f-2552-2ea8911a64e7@2ndquadrant.com> <25A09FA8-5B0E-447D-97FB-F37F3B0E34E9@postgrespro.ru> Cc: Michael Paquier , PostgreSQL Hackers , Simon Riggs , Robert Haas , Tom Lane From: Petr Jelinek Message-ID: Date: Thu, 2 Mar 2017 17:34:18 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On 02/03/17 13:23, Craig Ringer wrote: > On 2 March 2017 at 16:20, Stas Kelvich wrote: >> >>> On 2 Mar 2017, at 11:00, Craig Ringer wrote: >>> >>> We already have it, because we just decoded the PREPARE TRANSACTION. >>> I'm preparing a patch revision to demonstrate this. >> >> Yes, we already have it, but if server reboots between commit prepared (all >> prepared state is gone) and decoding of this commit prepared then we loose >> that mapping, isn’t it? > > I was about to explain how restart_lsn works again, and how that would > mean we'd always re-decode the PREPARE TRANSACTION before any COMMIT > PREPARED or ROLLBACK PREPARED on crash. But... > > Actually, the way you've implemented it, that won't be the case. You > treat PREPARE TRANSACTION as a special-case of COMMIT, and the client > will presumably send replay confirmation after it has applied the > PREPARE TRANSACTION. In fact, it has to if we want 2PC to work with > synchronous replication. This will allow restart_lsn to advance to > after the PREPARE TRANSACTION record if there's no other older xact > and we see a suitable xl_running_xacts record. So we wouldn't decode > the PREPARE TRANSACTION again after restart. > Unless we just don't let restart_lsn to go forward if there is 2pc that wasn't decoded yet (twopcs store the prepare lsn) but that's probably too much of a kludge. > > It's also worth noting that with your current approach, 2PC xacts will > produce two calls to the output plugin's commit() callback, once for > the PREPARE TRANSACTION and another for the COMMIT PREPARED or > ROLLBACK PREPARED, the latter two with a faked-up state. I'm not a > huge fan of that. It's not entirely backward compatible since it > violates the previously safe assumption that there's a 1:1 > relationship between begin and commit callbacks with no interleaving, > for one thing, and I think it's also a bit misleading to send a > PREPARE TRANSACTION to a callback that could previously only receive a > true commit. > > I particularly dislike calling a commit callback for an abort. So I'd > like to look further into the interface side of things. I'm inclined > to suggest adding new callbacks for 2pc prepare, commit and rollback, > and if the output plugin doesn't set them fall back to the existing > behaviour. Plugins that aren't interested in 2PC (think ETL) should > probably not have to deal with it, we might as well just send them > only the actually committed xacts, when they commit. > I think this is a good approach to handle it. -- Petr Jelinek http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers