agora inbox for pgpool-committers@postgresql.org  
help / color / mirror / Atom feed
From: Tatsuo Ishii <ishii@postgresql.org>
To: pgpool-committers@lists.postgresql.org
Subject: pgpool: Fix do_query to send sync rather than flush.
Date: Sun, 02 Aug 2026 06:34:34 +0000
Message-ID: <E1wqPmL-0000000DhOS-445k@gothos.postgresql.org> (raw)

Fix do_query to send sync rather than flush.

When in extended query mode and no explicit transaction has started
(i.e. implicit transaction), do_query issues a flush message after
execute message. But this does not close the implicit transaction and
"DISCARD ALL" in reset_query_list failed with:

 "DISCARD ALL cannot run inside a transaction block"

This could happen when query cache is enabled. After an execute and
sync are issued, pgpool generates internal query in extended query
mode using do_query:

SELECT oid FROM pg_catalog.pg_database WHERE datname = 'test'

Since do_query never issued a sync for this query, the implicit
transaction opened by do_query never closed and raised the error.

To fix the issue, send a sync message, rather than a flush message.
Sync will close the unamed portal in an implicit transaction. But to
run an unnamed portal, we need to issue bind message and re-create a
unnamed portal anyway.

Note: the author created the patch for fixing "idle in transaction"
left in pg_stat_activity, but I failed to reproduce the
issue. However, since I found the patch solves the issue above, I
decided to commit the patch anyway.

Author: Achilleas Mantzios <a.mantzios@cloud.gatewaynet.com>
Reviewed-by: Tatsuo Ishii <ishii@postgresql.org>
Discussion: https://www.postgresql.org/message-id/25939319-d77c-4df9-9e65-dfb1637ccd33%40cloud.gatewaynet.com
Backpatch-through: v4.3

Branch
------
V4_5_STABLE

Details
-------
https://git.postgresql.org/gitweb?p=pgpool2.git;a=commitdiff;h=a6ac3ea54cc6c7d4b251f843154589a5d6dce...

Modified Files
--------------
src/protocol/pool_process_query.c | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)



view thread (6+ messages)  latest in thread

Message-ID: <E1wqPmL-0000000DhOS-445k@gothos.postgresql.org>
Permalink:  ../E1wqPmL-0000000DhOS-445k@gothos.postgresql.org/
Also on:    postgresql.org/message-id/E1wqPmL-0000000DhOS-445k@gothos.postgresql.org

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgpool-committers@postgresql.org
  Cc: ishii@postgresql.org, pgpool-committers@lists.postgresql.org
  Subject: Re: pgpool: Fix do_query to send sync rather than flush.
  In-Reply-To: <E1wqPmL-0000000DhOS-445k@gothos.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox