agora inbox for pgpool-committers@postgresql.org
help / color / mirror / Atom feedFrom: Taiki Koshino <koshino@sraoss.co.jp>
To: pgpool-committers@lists.postgresql.org
Subject: pgpool: Fix premature Sync during extended-query pipelines
Date: Fri, 18 Sep 2026 07:17:31 +0000
Message-ID: <E1x7Sqg-0000000F9P5-3ofu@gothos.postgresql.org> (raw)
Fix premature Sync during extended-query pipelines
Pgpool-II could send an internal Sync before receiving the terminating
Sync from the frontend while processing an extended-query pipeline.
Because ReadyForQuery is not returned until Sync is processed, the
backend transaction state may still indicate idle while an implicit
transaction is in progress. A later Parse could therefore cause
Pgpool-II to send an internal Sync based on the stale transaction state,
prematurely ending the implicit transaction.
Track whether Pgpool-II is waiting for a frontend Sync and prevent Parse
from sending an internal Sync while processing the same pipeline.
Additional handling is required when statements in the pipeline are
sent to different backend nodes.
In native replication and snapshot isolation modes, send a SELECT
following a non-SELECT in the same pipeline to all backend nodes. This
ensures that an error aborts the implicit transaction on every node.
In snapshot isolation mode, also close the internal transaction when
the frontend Sync is processed.
In streaming replication mode, defer Sync to the primary when the
pipeline has executed statements on both the primary and a standby.
Process the standby result first and, if it reports an error, raise an
intentional error on the primary before sending the deferred Sync.
This prevents the primary from committing changes before the standby
result is known.
This fixes pipelines such as:
CREATE TABLE test(i int);
SELECT * FROM missing_table;
If the SELECT fails, the implicit transaction is rolled back and the
table created earlier in the pipeline does not remain.
The fix was verified in raw, native replication, snapshot isolation,
and streaming replication modes.
Author: Taiki Koshino <koshino@sraoss.co.jp>
Discussion: https://github.com/pgpool/pgpool2/issues/174
Backpatch-through: v4.3
Branch
------
V4_4_STABLE
Details
-------
https://git.postgresql.org/gitweb?p=pgpool2.git;a=commitdiff;h=81f75c263f5cd10e613cdc291593241f45ea6...
Modified Files
--------------
src/context/pool_session_context.c | 101 +++++++++++++++++
src/include/context/pool_session_context.h | 32 ++++++
src/include/protocol/pool_proto_modules.h | 2 +-
src/protocol/pool_process_query.c | 8 ++
src/protocol/pool_proto_modules.c | 170 ++++++++++++++++++++++++++++-
5 files changed, 307 insertions(+), 6 deletions(-)
view thread (6+ messages) latest in thread
Message-ID: <E1x7Sqg-0000000F9P5-3ofu@gothos.postgresql.org>
Permalink: ../E1x7Sqg-0000000F9P5-3ofu@gothos.postgresql.org/
Also on: postgresql.org/message-id/E1x7Sqg-0000000F9P5-3ofu@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: koshino@sraoss.co.jp, pgpool-committers@lists.postgresql.org
Subject: Re: pgpool: Fix premature Sync during extended-query pipelines
In-Reply-To: <E1x7Sqg-0000000F9P5-3ofu@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