Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1co3aw-0005D9-Hw for pgsql-hackers@arkaria.postgresql.org; Wed, 15 Mar 2017 07:43:42 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1co3aw-0002Ou-4N for pgsql-hackers@arkaria.postgresql.org; Wed, 15 Mar 2017 07:43:42 +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.84_2) (envelope-from ) id 1co3ZR-0007Ij-5s for pgsql-hackers@postgresql.org; Wed, 15 Mar 2017 07:42:09 +0000 Received: from mail-wr0-x234.google.com ([2a00:1450:400c:c0c::234]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1co3ZN-0004LY-RW for pgsql-hackers@postgresql.org; Wed, 15 Mar 2017 07:42:08 +0000 Received: by mail-wr0-x234.google.com with SMTP id u48so5166046wrc.0 for ; Wed, 15 Mar 2017 00:42:05 -0700 (PDT) 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=nDFlK6R85A3kg6r2ZC+F2zfpBXmsUtOVX4AiIbImPM4=; b=IhE0D4oWlqAGJLc00Wg1D0GWnRZ0XfZeKBlkmbsEaRbe2qeo2X/Aui3COMr4gge6di wX88ecdXIP5F52FqDHPFvdyqOwR4c2AIVVS5xchORCizJ+jFPqswW2Z+0jfEmCPWDZj/ tGseDn0w/5zrNv80uZ5ToZF/YhXP1rdupKndV4QASytkkUQIyTECICt12PcDYX5agAZ5 Gu8Wi10Q0jeFhuFwnDBYEp5yv84Ku4OEWXX6NEQF5tKX3CTJUeIb3Yi82jHo/d/0XJIG 5jcUVitrumiN8o+6mqyxzgcdmC8f+18iDBQEaTw2AuShd8QGYshliNASm2DUPH6ID7fC tj7g== 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=nDFlK6R85A3kg6r2ZC+F2zfpBXmsUtOVX4AiIbImPM4=; b=e/OG1WAjlX0Q9TB0HU7UtMePgbWmuHlqI7ZhRNbX1+3Fdycx4Y5nRPkpqQJQSOWW3z 7YrNv3r0SBQmAC5a+AH2zWACHYfFcVDpOWmHrlruVykT5Uh7eg9poCO5qDujuxcMnd3Q kIevKSqg82kcxDKe0jIOU3FucJHPDQHAafJSpSSgDbP/SsbjLilV74nqOmYLO1CMOzBm yZinPOejkyXagCJTiVgig6IHV+NC0bn+vTA7wcFVsMdZynHLjJl/lnLxEI+fjoNnLDXq GARG3Y/U3yA9KaSMkIzESIuTrMqLB+VtCKALoneU46+6by2PDwqwFZnpJior+ejUw97T vAaQ== X-Gm-Message-State: AFeK/H0w6MQ+XYRWSaxxjtGT2KJzRG9j/Ugik1kwCNsr53EwmQr3drECtWwVbfTcQ6Tn14j8 X-Received: by 10.223.176.87 with SMTP id g23mr1532600wra.12.1489563724770; Wed, 15 Mar 2017 00:42:04 -0700 (PDT) Received: from [192.168.0.105] (150.123.broadband11.iol.cz. [90.178.123.150]) by smtp.gmail.com with ESMTPSA id x25sm1291405wrx.4.2017.03.15.00.42.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Mar 2017 00:42:03 -0700 (PDT) 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: <11fb4e6c-58f2-7a41-ea58-c285e53c8d19@2ndquadrant.com> Date: Wed, 15 Mar 2017 08:42:03 +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 17:34, Petr Jelinek wrote: > 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. >> Thinking about this some more. Why can't we use the same mechanism standby uses, ie, use xid to identify the 2PC? If output plugin cares about doing 2PC in two phases, it can send xid as part of its protocol (like the PG10 logical replication and pglogical do already) and simply remember on downstream the remote node + remote xid of the 2PC in progress. That way there is no need for gids in COMMIT PREPARED and this patch would be much simpler (as the tracking would be left to actual replication implementation as opposed to decoding). Or am I missing something? -- 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