Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l9889-0003GV-KB for pgsql-hackers@arkaria.postgresql.org; Mon, 08 Feb 2021 15:07:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1l9887-000378-Rd for pgsql-hackers@arkaria.postgresql.org; Mon, 08 Feb 2021 15:07:11 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l987V-00036J-PG for pgsql-hackers@lists.postgresql.org; Mon, 08 Feb 2021 15:06:33 +0000 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1l987S-0005AB-61 for pgsql-hackers@postgresql.org; Mon, 08 Feb 2021 15:06:32 +0000 Received: by mail-wr1-x42d.google.com with SMTP id h12so1251921wrw.6 for ; Mon, 08 Feb 2021 07:06:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=5/NdrNBU21xHhPABA1n8jg9lFvriZsTg0ZfO+gEI5yI=; b=Tg/prBhX0gaOCEhrDzHbaiN1wbt0ZwXKUkJeoY1gLo/9nYHlFAfAke+6iuqqkPAvUE QsfJqWakH4MSGct2NpsVCIM25Y8MG1e3VaH8XyrjKrK1Wy2fEOSk2RJcVX9bAG6umDLi sjU6p5gq/bIi4a+jlOhCUDqOp4g+2IiT1NLgxqaHFevaqKakP1J3nkXVy4ATEeXGkyou k/TXTiQeeUBFMQUlTx/CiIrDOoHHTMI5Xy8yjbv1+a68ZhVHEIHVYfGifngezE8kzdND 0AkOwjAcGlhDVsYRtYgiDPtvqRISQk3jvrsLyvEGh/FKFbJzb/u0IKKjlFM9rT7kOVdz WrBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=5/NdrNBU21xHhPABA1n8jg9lFvriZsTg0ZfO+gEI5yI=; b=JtV7aoj5lHQmVja7iDSpCwuZ3K37XffPMD7YrEuiAcZ+TN8XFfflTV/skK5RARpQvk cWrOkRJxymKrlOx6VYG9B5ttXeoIz+QEBztAppOc29fIkWEdaxde/OIcgVrxkKI+Yw+t 18Lt906+BVg9+qNfsaTXYKrPcKukQmtnUcXfPNGipAN4e57UtTnQ7cI+HVca8tik7GMe RgBWPlu7+gzbl669vdghGUxJqyp0I/IlUx1eSg++je9UtBPQOenJu11h1UE6z87rOlLA 4JErI0brfiBkOsLujXPBUqAmkOYsPQ3YyCXrzDIfSK7xxgamAGo8Lq6zjEA7GSEh9si5 NTdw== X-Gm-Message-State: AOAM533yXYX3g6u16S/msEvXR7paZy9/dAKh6LJ8WkifwBqCkYzJU6Ik VoGETRL+vp8nMJj7nJAsHvKbRIfavYMqDhPa/dNsDWs23ENEhG54uxDTPHVYDTASsOG1SMxfB0n BIhBYriar8mg6Cs/1ov+okCnzL3pG7FTxmfxxQ8zAkY7TK1f+aqdSg25cmpdDXPpuzEGhH4FcYA pTbp58LQWI+8EtxKZ5OPRIRF79IhGIUHHzkbp7 X-Google-Smtp-Source: ABdhPJzfOBEJ6HuZ/RCEPw99p0j9k/GatDAwYK12KOjU6GhGxHbxeoYWj/U9zFmdZNVleXhl0BqQCQ== X-Received: by 2002:adf:b64f:: with SMTP id i15mr19715055wre.279.1612796787636; Mon, 08 Feb 2021 07:06:27 -0800 (PST) Received: from [10.80.18.219] (pool1-225.cgn.as8758.net. [212.25.6.225]) by smtp.gmail.com with ESMTPSA id b15sm11269517wrr.47.2021.02.08.07.06.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 08 Feb 2021 07:06:27 -0800 (PST) Subject: Re: repeated decoding of prepared transactions To: Amit Kapila , Markus Wanner Cc: pgsql-hackers , Ajin Cherian , Simon Riggs , ashutosh.bapat.oss@gmail.com, petr.jelinek@enterprisedb.com References: From: Markus Wanner Message-ID: Date: Mon, 8 Feb 2021 16:06:30 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-CLOUD-SEC-AV-Info: enterprisedb,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hello Amit, thanks for your very quick response. On 08.02.21 11:13, Amit Kapila wrote: > /* > * It is possible that this transaction is not decoded at prepare time > * either because by that time we didn't have a consistent snapshot or it > * was decoded earlier but we have restarted. We can't distinguish between > * those two cases so we send the prepare in both the cases and let > * downstream decide whether to process or skip it. We don't need to > * decode the xact for aborts if it is not done already. > */ The way I read the surrounding code, the only case a 2PC transaction does not get decoded a prepare time is if the transaction is empty. Or are you aware of any other situation that might currently happen? > (unless the server needs to be restarted due to some reason) Right, the repetition occurs only after a restart of the walsender in between a prepare and a commit prepared record. > That anyway is true without this work as well where restart_lsn can be > advanced on commits. We haven't changed anything in that regard. I did not mean to blame the patch, but merely try to understand some of the design decisions behind it. And as I just learned, even if we managed to avoid the repetition, a restarted walsender still needs to see prepared transactions as in-progress in its snapshots. So we cannot move forward the restart_lsn to after a prepare record (until the final commit or rollback is consumed). Best Regards Markus