Permalink
Browse files

Fix ProcessFrontendResponse() handling of Parse message in

master/slave mode. If it's inside transaction, enable
master_slave_dml, which means execute parse on master only.
This will prevent unwanted parase executed on slave, which holds
at least AccessShareLock on tables until transaction commits.
It seems unamed statement does not release the lock until execute.

Please note that, even with this fix, bind state will remain on slave
if JDBC issues parse with autocommit off. This is because BEGIN
parsed, bind on both master and slave but execute only on
master. However, this is not harmfull since parse/bind does not hold
any locks on tables.

Also add some logging statemets.
  • Loading branch information...
1 parent 2af75e5 commit 49ac54117d91971392de28607c713160b5e3cd14 t-ishii committed Dec 2, 2009
Showing with 22 additions and 4 deletions.
  1. +22 −4 pool_proto_modules.c
View
@@ -1,6 +1,6 @@
/* -*-pgsql-c-*- */
/*
- * $Header: /cvsroot/pgpool/pgpool-II/pool_proto_modules.c,v 1.25 2009/11/15 08:27:35 t-ishii Exp $
+ * $Header: /cvsroot/pgpool/pgpool-II/pool_proto_modules.c,v 1.26 2009/12/02 14:11:21 t-ishii Exp $
*
* pgpool: a language independent connection pool server for PostgreSQL
* written by Tatsuo Ishii
@@ -958,6 +958,7 @@ POOL_STATUS Parse(POOL_CONNECTION *frontend,
int deadlock_detected = 0;
int insert_stmt_with_lock = 0;
POOL_STATUS status;
+ char per_node_statement_log_buffer[1024];
/* read Parse packet */
if (pool_read(frontend, &len, sizeof(len)) < 0)
@@ -1120,6 +1121,8 @@ POOL_STATUS Parse(POOL_CONNECTION *frontend,
}
/* send to master node */
+ snprintf(per_node_statement_log_buffer, sizeof(per_node_statement_log_buffer), "Parse: %s", stmt);
+ per_node_statement_log(backend, MASTER_NODE_ID, per_node_statement_log_buffer);
if (send_extended_protocol_message(backend, MASTER_NODE_ID,
"P", len, string))
{
@@ -1174,9 +1177,14 @@ POOL_STATUS Parse(POOL_CONNECTION *frontend,
MAJOR(backend)))
return POOL_END;
}
- else if (send_extended_protocol_message(backend, i,
- "P", len, string))
- return POOL_END;
+ else
+ {
+ snprintf(per_node_statement_log_buffer, sizeof(per_node_statement_log_buffer), "Parse: %s", stmt);
+ per_node_statement_log(backend, i, per_node_statement_log_buffer);
+
+ if (send_extended_protocol_message(backend, i,"P", len, string))
+ return POOL_END;
+ }
}
}
@@ -1644,6 +1652,16 @@ POOL_STATUS ProcessFrontendResponse(POOL_CONNECTION *frontend,
case 'P': /* Parse message */
allow_close_transaction = 0;
+
+ if (MASTER_SLAVE &&
+ (TSTATE(backend) != 'I' || receive_extended_begin))
+ {
+ pool_debug("kind: %c master_slave_dml enabled", fkind);
+ master_slave_was_enabled = 1;
+ MASTER_SLAVE = 0;
+ master_slave_dml = 1;
+ }
+
status = Parse(frontend, backend);
break;

0 comments on commit 49ac541

Please sign in to comment.