[pgpool-committers: 9400] pgpool: Allow to load balance PREPARE/EXECUTE/DEALLOCATE.
Tatsuo Ishii
ishii at sraoss.co.jp
Fri May 19 15:41:15 JST 2023
Allow to load balance PREPARE/EXECUTE/DEALLOCATE.
Previously PREPARE/EXECUTE/DEALLOCATE are not load balanced. In
streaming replication/logical replication mode, they were sent to
always primary node. In native replication/snapshot isolation
mode,they were always sent to all nodes.
Now they can be load balanced if the SQL statement prepared by PREPARE
command is a read only SELECT.
For this purpose following changes were made:
- is_select_query() looks into "query" member if node is
PrepareStmt. Also second argument "sql" (query string) is not now
mandatory. If sql is NULL, warning is emitted and this function
returns false. If allow_sql_comments is off and node is PrepareStmt
and query is SelectStmt, is_select_query() does not return false
anymore.
- pool_has_function_call() looks into "query" member if node is
PrepareStmt.
- Add PREPARE/EXECUTE/DEALLOCATE test cases to 001.load_balance test.
- Add send_prepare() function which is similar to parse_before_bind in
extended query protocol case to keep up
disable_load_balance_on_write rule. send_prepare() is called by
SimpleQuery() when EXECUTE message is sent by frontend in SL mode so
that it sends PREPARE message to primary node if it has not sent to
primary because of load balance. Note that send_prepare() does
nothing if the clustering mode is other than SL mode. In native
replication mode or snapshot isolation mode, all backend has the
same data, and there's no point to keep up
disable_load_balance_on_write rule.
- Remove descriptions of restrictions regarding load balance for
PREPARE/EXECUTE/DEALLOCATE in "Restrictions" section in the docs.
Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2023-May/004334.html
Branch
------
master
Details
-------
https://git.postgresql.org/gitweb?p=pgpool2.git;a=commitdiff;h=66fa78e2b5b97c116fce914f474ef562febbfa10
Modified Files
--------------
doc.ja/src/sgml/restrictions.sgml | 9 --
doc/src/sgml/restrictions.sgml | 10 --
src/context/pool_query_context.c | 19 ++-
src/protocol/pool_process_query.c | 33 +++--
src/protocol/pool_proto_modules.c | 134 +++++++++++++++++++++
.../tests/001.load_balance/expected/expected1-r | 6 +
.../tests/001.load_balance/expected/expected1-s | 4 +
.../tests/001.load_balance/expected/expected6-r | 91 +++++++++++++-
.../tests/001.load_balance/expected/expected6-s | 87 ++++++++++++-
.../tests/001.load_balance/expected/expected7-r | 6 -
.../regression/tests/001.load_balance/sql/6.sql | 27 +++++
src/test/regression/tests/001.load_balance/test.sh | 19 +--
src/utils/pool_select_walker.c | 7 ++
13 files changed, 402 insertions(+), 50 deletions(-)
More information about the pgpool-committers
mailing list