[pgpool-committers: 9144] pgpool: Fix kind mimatch error with DEALLOCATE

Tatsuo Ishii ishii at sraoss.co.jp
Tue Jan 31 19:03:38 JST 2023


Fix kind mimatch error with DEALLOCATE

When conditions below are all met:
- streaming replication mode
- load balance node is other than primary
- PREPARE is used in a multi-statement query

Kind mimatch error occurs.

For DEALLOCATE pool_where_to_send() sets the nodes to be sent to all
backend if pgpool failed to find a prepared statement previously
received. For example with "SELECT 1\;PREPARE foo;", pgpool ignores
"PREPARE" part and just sends the whole multi-statement query to
primary. So primary actually has the prepared statement "foo" but
pgpool thinks that there's no prepared statement named "foo". And
pgpool sends DEALLOCATE to both primary and standby, then a kind
mismatch error raised. Fix is, just sending DEALLOCATE to primary node
in this case if pgpool is in streaming replication mode.  Same thing
can be said to EXECUTE too. I fixed this and merge similar treatment
with EXECUTE into where_to_send_deallocate() to make the code simpler.

I also found another bug: in replication mode or SI mode, pgpool needs
to send multi-statement query to all backend because the
multi-statement query maybe a write query. However pgpool sends to
main node only in this case.

Test cases are added to 071..execute_and_deallocate.

Backpatch-through: 4.0

Problem reported in:
https://www.pgpool.net/mantisbt/view.php?id=780

Branch
------
V4_0_STABLE

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

Modified Files
--------------
src/context/pool_query_context.c                   | 94 ++++++++++++++++------
.../tests/071.execute_and_deallocate/test.sh       | 22 ++++-
2 files changed, 87 insertions(+), 29 deletions(-)



More information about the pgpool-committers mailing list