diff --git a/server/core/queryclassifier.cc b/server/core/queryclassifier.cc index 6e271b464..08b605ed8 100644 --- a/server/core/queryclassifier.cc +++ b/server/core/queryclassifier.cc @@ -638,11 +638,19 @@ void QueryClassifier::log_transaction_status(GWBUF* querybuf, uint32_t qtype) uint8_t* packet = GWBUF_DATA(querybuf); unsigned char command = packet[4]; int len = 0; - char* sql; + std::string sqldata; + char* sql = (char*)""; char* qtypestr = qc_typemask_to_string(qtype); - if (!modutil_extract_SQL(querybuf, &sql, &len)) + + if (qc_mysql_is_ps_command(command)) { - sql = (char*)""; + sqldata = "ID: " + std::to_string(mysql_extract_ps_id(querybuf)); + sql = (char*)sqldata.c_str(); + len = sqldata.length(); + } + else + { + modutil_extract_SQL(querybuf, &sql, &len); } if (len > QC_TRACE_MSG_LEN) diff --git a/server/modules/routing/readwritesplit/rwsplit_route_stmt.cc b/server/modules/routing/readwritesplit/rwsplit_route_stmt.cc index f420b9916..60b2637a8 100644 --- a/server/modules/routing/readwritesplit/rwsplit_route_stmt.cc +++ b/server/modules/routing/readwritesplit/rwsplit_route_stmt.cc @@ -1178,6 +1178,12 @@ bool RWSplitSession::handle_got_target(GWBUF* querybuf, RWBackend* target, bool */ bool success = target->write(send_buf, response); + if (orig_id) + { + // Put the original ID back in case we try to route the query again + replace_binary_ps_id(querybuf, orig_id); + } + if (success) { if (store) @@ -1219,12 +1225,6 @@ bool RWSplitSession::handle_got_target(GWBUF* querybuf, RWBackend* target, bool } else { - if (orig_id) - { - // Put the original ID back in case we try to route the query again - replace_binary_ps_id(querybuf, orig_id); - } - MXS_ERROR("Routing query failed."); } diff --git a/server/modules/routing/readwritesplit/rwsplitsession.cc b/server/modules/routing/readwritesplit/rwsplitsession.cc index 7ad228a96..27c6d7c39 100644 --- a/server/modules/routing/readwritesplit/rwsplitsession.cc +++ b/server/modules/routing/readwritesplit/rwsplitsession.cc @@ -994,7 +994,7 @@ void RWSplitSession::handleError(GWBUF* errmsgbuf, if (m_current_master && m_current_master->in_use() && m_current_master == backend) { - MXS_INFO("Master '%s' failed", backend->name()); + MXS_INFO("Master '%s' failed: %s", backend->name(), extract_error(errmsgbuf).c_str()); /** The connection to the master has failed */ if (!backend->is_waiting_result()) @@ -1066,7 +1066,7 @@ void RWSplitSession::handleError(GWBUF* errmsgbuf, } else { - MXS_INFO("Slave '%s' failed", backend->name()); + MXS_INFO("Slave '%s' failed: %s", backend->name(), extract_error(errmsgbuf).c_str()); if (m_target_node && m_target_node == backend && session_trx_is_read_only(problem_dcb->session)) {