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.96) (envelope-from ) id 1x3ZUY-006W1k-13 for pgpool-general@arkaria.postgresql.org; Mon, 07 Sep 2026 13:34:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1x3ZUV-001lUS-0O for pgpool-general@arkaria.postgresql.org; Mon, 07 Sep 2026 13:34:31 +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.96) (envelope-from ) id 1x3Syl-00HKWF-0z for pgpool-general@lists.postgresql.org; Mon, 07 Sep 2026 06:37:19 +0000 Received: from mail.gatewaynet.com ([185.90.37.66]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1x3Syi-00000003MJA-0frl for pgpool-general@lists.postgresql.org; Mon, 07 Sep 2026 06:37:18 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.gatewaynet.com (Postfix) with ESMTP id 81FF52A2444; Mon, 7 Sep 2026 09:37:14 +0300 (EEST) Authentication-Results: mail.gatewaynet.com (amavis); dkim=pass (2048-bit key) header.d=gatewaynet.com Received: from mail.gatewaynet.com ([127.0.0.1]) by localhost (mail.gatewaynet.com [127.0.0.1]) (amavis, port 10032) with ESMTP id Fwi9qn-SeM59; Mon, 7 Sep 2026 09:37:14 +0300 (EEST) Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.gatewaynet.com (Postfix) with ESMTP id 8C82B2A242E; Mon, 7 Sep 2026 09:37:13 +0300 (EEST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.gatewaynet.com 8C82B2A242E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gatewaynet.com; s=5495D85E-17AE-11EA-94AA-A4C7E0C5309B; t=1788763033; bh=4bz6mc5G/ljSflku5fd9DtHdfDbK1sTlBn8Mxu0nP0g=; h=Date:From:To:Message-ID:MIME-Version; b=Gv+yPOsyUfKVkrcyjtJZ+0cpUYpDgeeL0ICxolvBJd9OZhXi4sKE9gQ91cKgOlTCP dTwcbn9oFcAncb5L+LccVS7VS+DCXsbeANGe/3mzyMoPtMr/p1kriQr+ESC640dI4h sPUCr1SB2HGFKC1+68sTLHDSwE0mRudb3F0eTzRNHI/aByVL84oJuMgGxDbV+etjZh I9U8a1qwG7FjqWT1qPLLEqZP/hCnjtekfzfS/jVxphP4ZnqsUOW9qxwN64os5/AQWh 4j37ayrAdSmuGnghhgtj5R9kpdf7jn7ZgxL6utPoM/Ial9vZfLZtDFBo6bt9/fMJDI 1mxMXaTKz/1aQ== X-Virus-Scanned: amavis at mail.gatewaynet.com Received: from mail.gatewaynet.com ([127.0.0.1]) by localhost (mail.gatewaynet.com [127.0.0.1]) (amavis, port 10026) with ESMTP id zeWyzlNBHKE8; Mon, 7 Sep 2026 09:37:13 +0300 (EEST) Received: from mbox1.esocom.net (unknown [185.90.37.165]) by mail.gatewaynet.com (Postfix) with ESMTP id 613002A2468; Mon, 7 Sep 2026 09:37:13 +0300 (EEST) Date: Mon, 7 Sep 2026 09:36:55 +0300 (EEST) From: Achilleas Mantzios To: Tatsuo Ishii Cc: Achilleas Mantzios , pgpool-general@lists.postgresql.org Message-ID: <1353776274.747902.1788763015882.JavaMail.zimbra@gatewaynet.com> In-Reply-To: <20260907.062521.1780975513572548706.ishii@postgresql.org> References: <20260801.073525.510696094193506119.ishii@postgresql.org> <20260802.155039.1793042838842141111.ishii@postgresql.org> <20260907.062521.1780975513572548706.ishii@postgresql.org> Subject: Re: low level protocol, implicit transactions , "idle in transaction" issue MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [193.92.121.116] X-Mailer: Zimbra 10.1.20_GA_4893 (ZimbraWebClient - FF151 (Linux)/10.1.20_GA_4894) Thread-Topic: low level protocol, implicit transactions , "idle in transaction" issue Thread-Index: l1X8MVRCcDOtkHBdl27sU5o265DImA== List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Thanks for the follow up! -Achilleas Mantzios IT DEV - HEAD IT DEPT Dynacom Tankers Management LTD=20 (As Agents only) Email : itdev@gatewaynet.com ----- Original Message ----- From: "Tatsuo Ishii" To: "Achilleas Mantzios" Cc: pgpool-general@lists.postgresql.org, "ITDEV" Sent: Monday, 7 September, 2026 00:25:21 Subject: Re: low level protocol, implicit transactions , "idle in transacti= on" issue I found the commit: https://git.postgresql.org/gitweb/?p=3Dpgpool2.git;a=3Dcommit;h=3De4a3a0c13= e4b5e1a015aca3db238b21b88e73e2f [Fix do_query to send sync rather than flush.] introduced a bug. Here is a reproducer. Note that pgpool must be configured to disable load balancing (i.e. load_balance_node =3D off, or backend_weight0 =3D 1 and backend_weight1 =3D 0) to run the test by a reason explained later in this message. ----------------------------------------------------------------- $ psql -p 11000 -a -f failure.sql test DROP TABLE test; DROP TABLE -- start a pipeline \startpipeline -- CREATE a table CREATE TABLE test(i int); -- SELECT non-existent table, which raises an error, -- and aborts the implicit transaction started by the pipeline. SELECT * from a;=09 -- Recover from the error and closes the implicit transaction. \syncpipeline \endpipeline CREATE TABLE psql:failure.sql:11: ERROR: relation "a" does not exist LINE 1: SELECT * from a; ^ -- Try to SELECT the table created in the previous pipeline. -- This should fail because the creation of the table "test" was rollbacked= . SELECT * from test; i=20 --- (0 rows) ----------------------------------------------------------------- In this example, a table named "test" is created in a pipeline. Then a SELECT is executed. Because the SELECT tries to retrieve rows from non-existent table "a", it causes an error and a roll back of the implicit transaction started by the pipeline. As a result, the table "test" created in the pipeline does not exist at the end of the pipeline. However, a "sync" message was issued by do_query() while obtaining information regarding table "a". As the sync message caused commit of the implicit transaction started by the pipeline, creation of "test" was not roll backed by the subsequent erroneous SELECT. IMO this is a serious data consistency issue because it breaks the transaction semantics. If I directly connects to PostgreSQL or pgpool by the previous commit, and run the script, it ends up with: SELECT * from test; psql:failure.sql:14: ERROR: relation "test" does not exist LINE 1: SELECT * from test; ^ which is the expected behavior. Another bug: In the begging of this message, I wrote that pgpool must be configured to disable load balancing (i.e. load_balance_node =3D off, or backend_weight0 =3D 1 and backend_weight1 =3D 0) to run the test. I am going to explain the reason. When a pipeline including a write query and a read query starts, pgpool executes the write query on primary. The subsequent read query can be run on standby if load balance is enabled. So it is possible that implicit transaction including a write query runs on primary, and an implicit transaction including a read query runs on standby. Even if the transaction running on standby aborts by an error, it does not affect the transaction on primary. As a result, the transaction on primary successfully commits and the table "test" is created. So we have two problems: (1) An implicit transaction does not roll back when it should, due to an internal sync message. (2) An implicit transaction does not roll back when it should, due to load balance. To solve (1), I am going to revert the commit [Fix do_query to send sync rather than flush.] Of course this cancel the fix (issue with query cache) in the commit, but I think we should solve it in different way. For (2), I can't think of a solution right now. I need more time to think of a solution. Regards, -- Tatsuo Ishii SRA OSS K.K. English: http://www.sraoss.co.jp/index_en/ Japanese:http://www.sraoss.co.jp > On 8/2/26 09:50, Tatsuo Ishii wrote: >=20 >> Hi Achilleas, >> >>>> Ok but then how can we explain the system complaining about : >>>> >>>> "DISCARD ALL cannot run inside a transaction block" ? >>>> >>>> Apparently there was inside a transaction somehow, >>> It does not necessarily mean pg_stat_activity shows it as "idle in >>> transaction". From my experience, without issuing an explicit >>> transaction from client, pg_stat_activity shows "idle" or "active", >>> but never "idle in transaction". I guess PostgreSQL distinguish an >>> explicit transaction and an implicit transaction. >>> >>>> and upon hitting >>>> the home page the app (Quarkus) apart from the xaction in the logging >>>> table didn't start any other explicitly. >>>> >>>> Also the problem never manifested when against plain vanilla >>>> postgresql, or pgbouncer -> postgresql, >>>> >>>> And only when against pgbouncer -> pgpool -> >>>> postgresqlmemory_cache_enabled=C2=A0=3D true >>> Yes, in the case above, pgpool issues do_query which causes open >>> implicit transaction. But again, I think it does not cause >>> pg_stat_activity showing "idle in transaction". >> Patch pushed to all supported branches. >> https://git.postgresql.org/gitweb/?p=3Dpgpool2.git;a=3Dcommit;h=3De4a3a0= c13e4b5e1a015aca3db238b21b88e73e2f >> >> As I wroite in the commit messages, I hoped the patch fixes "DISCARD >> ALL cannot run inside a transaction block" error. >> >> However, the original intension of the patch was to fix "idle in >> transaction" left in pg_stat_activity. Please try the 4.7 patch if you >> like. >=20 > Thank you Tatsuo for the hard work you are putting into pgpool ! >=20 > I don't quite feel right about the course of events during this > thread, meaning me resorting to our local AI to pull the iron out of > the fire, I hope to more personal involvement next round! at least I > wish so. >=20 >> >> https://git.postgresql.org/gitweb/?p=3Dpgpool2.git;a=3Dcommit;h=3Dbc3689= a2d62f2083699b86feb267e90296913c26