Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qjMMc-00Ae9S-Or for pgsql-bugs@arkaria.postgresql.org; Thu, 21 Sep 2023 16:17:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qjMMa-00DEcr-IH for pgsql-bugs@arkaria.postgresql.org; Thu, 21 Sep 2023 16:17:12 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qjMMa-00DEcY-91 for pgsql-bugs@lists.postgresql.org; Thu, 21 Sep 2023 16:17:12 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qjMMT-006YSx-0K for pgsql-bugs@lists.postgresql.org; Thu, 21 Sep 2023 16:17:11 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 38LGGupZ710009; Thu, 21 Sep 2023 12:16:56 -0400 From: Tom Lane To: "=?UTF-8?B?5YiY55u4KOS9keeGmSk=?=" cc: "Laurenz Albe" , "pgsql-bugs" Subject: =?UTF-8?Q?Re:_=E5=9B=9E=E5=A4=8D=EF=BC=9ARe:_BUG_#18118:_bug_repo?= =?UTF-8?Q?rt_for_COMMIT_AND_CHAIN_feature?= In-reply-to: <511e16d9-9deb-44d8-a64f-712bd18ebc12.evan.lx@alibaba-inc.com> References: <18118-4b72fcbb903aace6@postgresql.org>, <511e16d9-9deb-44d8-a64f-712bd18ebc12.evan.lx@alibaba-inc.com> Comments: In-reply-to "=?UTF-8?B?5YiY55u4KOS9keeGmSk=?=" message dated "Thu, 21 Sep 2023 15:12:18 +0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <710007.1695313016.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 21 Sep 2023 12:16:56 -0400 Message-ID: <710008.1695313016@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk "=3D?UTF-8?B?5YiY55u4KOS9keeGmSk=3D?=3D" writes: > This problem seems to have been solved in v15 and v16. Because of this p= atch (12d768e70497afc5a57acf73c251316997b5175a), the use of static variabl= es has been cancelled. But this problem can obviously be reproduced on v14= (and perhaps v12 v13). Try the following SQL again. Oooh ... I see the problem. It's not really about the use of static variables. In the older branches, CommitTransactionCommand does if (s->chain) SaveTransactionCharacteristics(); .... if (s->chain) RestoreTransactionCharacteristics(); but if we're closing out any subtransactions then *those two checks are inspecting different "s" structs*, and the "chain" flag has only been set in the bottom of the state stack. 12d768e70 fixed the problem rather accidentally, because I removed the initial "if (s->chain)" test to avoid a compiler warning. I think we can just do the same in the back branches, without having to address the question of whether it'd be OK to break API for SaveTransactionCharacteristics and RestoreTransactionCharacteristics. regards, tom lane