View Issue Details

IDProjectCategoryView StatusLast Update
0000189Pgpool-IIBugpublic2016-04-15 13:31
ReporterharukatAssigned Tot-ishii 
PrioritynormalSeverityminorReproducibilityhave not tried
Status resolvedResolutionopen 
Product Version3.4.0 
Target Version3.4.0Fixed in Version 
Summary0000189: kind mismatch error on master_slave_mode=on / load_lalance_mode=off
DescriptionIn the following settings:
 load_balance_mode = off
 master_slave_mode = on
 master_slave_sub_mode = 'stream'

and the following status:
 db1=# SHOW pool_nodes;
  node_id | hostname | port | status | lb_weight | role
 ---------+-----------+------+--------+-----------+---------
  0 | localhost | 5433 | 2 | 0.500000 | standby
  1 | localhost | 5432 | 2 | 0.500000 | primary
 (2 rows)

"BEGIN" (and other transaction statements) will be thrown incorrectly
to both nodes. It can cause a "kind mismatch" error.
It isn't happen when backend0 is primary.

The attached patch makes pgpool to handle "load_balance_mode=off"
as same as the case NO LOAD BALANCE comment is given. I think it can
privent this bug simply, but it may have a problem about feature stability.
TagsNo tags attached.

Activities

harukat

2016-04-07 14:53

developer  

pool_query_context.c.20160407.patch (856 bytes)
diff --git a/src/context/pool_query_context.c b/src/context/pool_query_context.c
index 3326654..0854783 100644
--- a/src/context/pool_query_context.c
+++ b/src/context/pool_query_context.c
@@ -314,9 +314,11 @@ void pool_where_to_send(POOL_QUERY_CONTEXT *query_context, char *query, Node *no
 	pool_clear_node_to_be_sent(query_context);
 
 	/*
-	 * If there is "NO LOAD BALANCE" comment, we send only to master node.
+	 * If there is "NO LOAD BALANCE" comment or load_balance_mode=off/
+	 * master_slave_mode, we send only to master node.
 	 */
-	if (!strncasecmp(query, NO_LOAD_BALANCE, NO_LOAD_BALANCE_COMMENT_SZ))
+	if (!strncasecmp(query, NO_LOAD_BALANCE, NO_LOAD_BALANCE_COMMENT_SZ)
+		|| (MASTER_SLAVE && !pool_config->load_balance_mode))
 	{
 		pool_set_node_to_be_sent(query_context,
 								 MASTER_SLAVE ? PRIMARY_NODE_ID : REAL_MASTER_NODE_ID);

harukat

2016-04-11 19:55

developer   ~0000775

I noticed additionally .

The variable "session_context->load_balance_node_id" does not initialize
when load_balance_mode is off, But this variable is refered in the function
pool_setall_node_to_be_sent() at that case.

We can also fix the bug with the following code.

*** ./context/pool_session_context.c 2016-04-11 19:54:13.136531528 +0900
--- ./context/pool_session_context.c.FIX 2016-04-11 19:54:06.705823626 +0900
***************
*** 86,91 ****
--- 86,93 ----
                        (errmsg("initializing session context"),
                                 errdetail("selected load balancing node: %d", backend->info->load_balancing_node)));
        }
+ else
+ session_context->load_balance_node_id = -1;

        /* Unset query is in progress */
        pool_unset_query_in_progress();

t-ishii

2016-04-15 08:31

developer   ~0000784

Last edited: 2016-04-15 08:33

View 2 revisions

The attached proposed patch is not quite correct because PRIMARY_NODE_ID only exists in the streaming replication mode. In the mean time I'm going accept the proposal (if load balance mode is off, SET or other commands, which are sent to all the DB nodes if load balance is on, are not necessarily sent to all the DB nodes.

I'm going to commit changes for this (different implementation from yours) to the master branch, which will also address the issue above.

t-ishii

2016-04-15 13:31

developer   ~0000785

Fix committed.

Issue History

Date Modified Username Field Change
2016-04-07 14:31 harukat New Issue
2016-04-07 14:31 harukat File Added: pool_query_context.c.20160407.patch
2016-04-07 14:49 harukat Summary master slave => kind mismatch error on master_slave_mode
2016-04-07 14:49 harukat Description Updated View Revisions
2016-04-07 14:49 harukat File Deleted: pool_query_context.c.20160407.patch
2016-04-07 14:49 harukat File Added: pool_query_context.c.20160407.patch
2016-04-07 14:50 harukat Summary kind mismatch error on master_slave_mode => kind mismatch error on master_slave_mode=on / load_lalance_mode=off
2016-04-07 14:53 harukat File Deleted: pool_query_context.c.20160407.patch
2016-04-07 14:53 harukat File Added: pool_query_context.c.20160407.patch
2016-04-08 11:40 t-ishii Assigned To => t-ishii
2016-04-08 11:40 t-ishii Status new => assigned
2016-04-11 19:55 harukat Note Added: 0000775
2016-04-15 08:31 t-ishii Note Added: 0000784
2016-04-15 08:33 t-ishii Note Edited: 0000784 View Revisions
2016-04-15 13:31 t-ishii Note Added: 0000785
2016-04-15 13:31 t-ishii Status assigned => resolved