Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cjCdz-0001YE-Hc for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Mar 2017 22:22:47 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cjCdz-0002tz-4H for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Mar 2017 22:22:47 +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 1cjCcK-0006Ya-DM for pgsql-hackers@postgresql.org; Wed, 01 Mar 2017 22:21:04 +0000 Received: from mail-wr0-x231.google.com ([2a00:1450:400c:c0c::231]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1cjCcH-0005xu-Lm for pgsql-hackers@postgresql.org; Wed, 01 Mar 2017 22:21:03 +0000 Received: by mail-wr0-x231.google.com with SMTP id u108so39983412wrb.3 for ; Wed, 01 Mar 2017 14:21:01 -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=ckjE2DRU6eqhaLmW1tXyHUuOdpb3dZFe2dE3Qa7J578=; b=Ch9gIkt+PMcWZhl3yHDhBTnmtDTI2qFLjo3i7C9ZFq8PgAMLNE8wVH6gVFxzRF5RcA OfTXoJVFMd8QZBSUSwa37tLDqlL30iax+/Oh7RqOEifG5Ab1fr1wXV1IVUAQomvxjycY SeT35FUwbGscwqxV8+OQE9Kjyxi9oW+Ru577hiuJ99ga1UBdSkgEf/wreV7+9QaAiy/x n8ass7hp7r2uLP+ksQocXX87rIt5DvnPrYRb62kBeS6rHCm2wFD8TwzkNWxKKoM1Lle+ 8PEKo7819srnB+rSpztCGQtn+2yJ56qTs1Ibb3ifPq4QBx0oN4dYo2/ff4q9iCbqgDSw zH1A== 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=ckjE2DRU6eqhaLmW1tXyHUuOdpb3dZFe2dE3Qa7J578=; b=Tz9bAcnzUfNGqBWxX4z5fYGgZfBkdJR1NkVMGDaSUI038Enhh2mfetvtHYSOwMGyUr egeroSbrGilyOgH8RSW0W/9pt0VeFLgWe0jr1MVUd7QKQyGwwyIPusuWRW/MjpKeCMSJ l53OZOzBXMGeaDOiDXW2uwzJe2aHZV3bRfkPK7uzLpdGV3GNv59KFWSJ0UM+MsnWy2/t bX7XJ9EwXTOF/7xntrIUx0VulIwtuz8dqpXAcS3JRbNdA9rvgZpnvW4ZnI3IKV0xgVvG bIfKwtiSPKdPhIVmLxhurcQ9CGzbVG8zGMhClIbmDDAJUeDOEvdbkx6j8nzfweHJ74Dz IndQ== X-Gm-Message-State: AMke39nnhi4e/ryjncftNu6d79bJU44pLGt7Bum4dB5g73Snlzh+LGG0L62282NUvgtF6e/1 X-Received: by 10.223.165.17 with SMTP id i17mr10343899wrb.62.1488406859190; Wed, 01 Mar 2017 14:20:59 -0800 (PST) Received: from [192.168.0.105] (150.123.broadband11.iol.cz. [90.178.123.150]) by smtp.gmail.com with ESMTPSA id x193sm8583218wme.23.2017.03.01.14.20.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Mar 2017 14:20:58 -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> Cc: Michael Paquier , PostgreSQL Hackers , Simon Riggs , Robert Haas , Tom Lane From: Petr Jelinek Message-ID: <46ebc39d-82a0-e59f-2552-2ea8911a64e7@2ndquadrant.com> Date: Wed, 1 Mar 2017 23:20:57 +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 01/03/17 10:24, Craig Ringer wrote: > On 9 February 2017 at 21:23, Stas Kelvich wrote: > >>> On 2 Feb 2017, at 00:35, Craig Ringer wrote: >>> >>> Stas was concerned about what happens in logical decoding if we crash between PREPSRE TRANSACTION and COMMIT PREPARED. But we'll always go back and decode the whole txn again anyway so it doesn't matter. >> >> Not exactly. It seems that in previous discussions we were not on the same page, probably due to unclear arguments by me. >> >> From my point of view there is no problems (or at least new problems comparing to ordinary 2PC) with preparing transactions on slave servers with something like “#{xid}#{node_id}” instead of GID if issuing node is coordinator of that transaction. In case of failure, restart, crash we have the same options about deciding what to do with uncommitted transactions. > > But we don't *need* to do that. We have access to the GID of the 2PC > xact from PREPARE TRANSACTION until COMMIT PREPARED, after which we > have no need for it. So we can always use the user-supplied GID. > >> I performed some tests to understand real impact on size of WAL. I've compared postgres -master with wal_level = logical, after 3M 2PC transactions with patched postgres where GID’s are stored inside commit record too. > > Why do you do this? You don't need to. You can look the GID up from > the 2pc status table in memory unless the master already did COMMIT > PREPARED, in which case you can just decode it as a normal xact as if > it were never 2pc in the first place. > > I don't think I've managed to make this point by description, so I'll > try to modify your patch to demonstrate. > If I understand you correctly you are saying that if PREPARE is being decoded, we can load the GID from the 2pc info in memory about the specific 2pc. The info gets removed on COMMIT PREPARED but at that point there is no real difference between replicating it as 2pc or 1pc since the 2pc behavior is for all intents and purposes lost at that point. Works for me. I guess the hard part is knowing if COMMIT PREPARED happened at the time PREPARE is decoded, but I existence of the needed info could be probably be used for that. -- 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