pgpool2.git / summary / log / commit / refs
commit ee51d9d1bcda597815bbea958cad82bb37f30765
Author: Tatsuo Ishii <ishii@postgresql.org>
Date: Mon Nov 04 12:51:04 2013 +0000
Fix load balance bug in replication mode.
When load_balance_mode = off, SELECTs including writing function
should be sent to all the DB nodes. Per [pgpool-general: 2221].
The bug was introduced in:
http://git.postgresql.org/gitweb/?p=pgpool2.git;a=commitdiff;h=1ac45a28258074ea4d9d902aca016f970d31f311
(3.3.1).
src/context/pool_query_context.c | 3 ++-
src/test/regression/tests/001.load_balance/test.sh | 22 +++++++++++++++++++++-
2 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/src/context/pool_query_context.c b/src/context/pool_query_context.c
index cf15282ce..c49cd98ff 100644
--- a/src/context/pool_query_context.c
+++ b/src/context/pool_query_context.c
@@ -516,7 +516,8 @@ void pool_where_to_send(POOL_QUERY_CONTEXT *query_context, char *query, Node *no
}
else
{
- if (is_select_query(node, query) && !pool_config->replicate_select)
+ if (is_select_query(node, query) && !pool_config->replicate_select &&
+ !pool_has_function_call(node))
{
/* only send to master node */
pool_set_node_to_be_sent(query_context, REAL_MASTER_NODE_ID);
diff --git a/src/test/regression/tests/001.load_balance/test.sh b/src/test/regression/tests/001.load_balance/test.sh
index 1ba7dc26f..5c279f09a 100755
--- a/src/test/regression/tests/001.load_balance/test.sh
+++ b/src/test/regression/tests/001.load_balance/test.sh
@@ -93,11 +93,31 @@ EOF
fi
# the SELECT should be executed on node 0
fi
+
+# in replication mode if load_balance_mode = off, SELECT query
+# including writing function should be sent to all the nodes.
+# per [pgpool-general: 2221].
+ echo "black_function_list = 'f1'" >> etc/pgpool.conf
+ echo "white_function_list = ''" >> etc/pgpool.conf
+ ./pgpool_reload
+ $PSQL test <<EOF
+SELECT f1(2); -- this should be sent to all the nodes
+EOF
+ fgrep "SELECT f1(2);" log/pgpool.log |grep "DB node id: 0">/dev/null 2>&1
+ if [ $? = 0 ];then
+ fgrep "SELECT f1(2);" log/pgpool.log |grep "DB node id: 1">/dev/null 2>&1
+ if [ $? = 0 ];then
+ # the SELECT should be executed on node 0 & 1
+ ok=`expr $ok + 1`
+ fi
+ # the SELECT should be executed on node 0
+ fi
+
fi
./shutdownall
- if [ $ok != 1];then
+ if [ $ok != 2 ];then
exit 1;
fi
[parent: cf095115ec32]