diff --git a/server/modules/routing/readwritesplit/readwritesplit.cc b/server/modules/routing/readwritesplit/readwritesplit.cc index 96acee35a..69cd91d16 100644 --- a/server/modules/routing/readwritesplit/readwritesplit.cc +++ b/server/modules/routing/readwritesplit/readwritesplit.cc @@ -632,26 +632,22 @@ RWSplitSession* RWSplit::newSession(MXS_SESSION *session) */ void RWSplitSession::close() { - if (!rses_closed) + close_all_connections(backends); + + if (MXS_LOG_PRIORITY_IS_ENABLED(LOG_INFO) && + sescmd_list.size()) { - rses_closed = true; - close_all_connections(backends); + std::string sescmdstr; - if (MXS_LOG_PRIORITY_IS_ENABLED(LOG_INFO) && - sescmd_list.size()) + for (mxs::SessionCommandList::iterator it = sescmd_list.begin(); + it != sescmd_list.end(); it++) { - std::string sescmdstr; - - for (mxs::SessionCommandList::iterator it = sescmd_list.begin(); - it != sescmd_list.end(); it++) - { - mxs::SSessionCommand& scmd = *it; - sescmdstr += scmd->to_string(); - sescmdstr += "\n"; - } - - MXS_INFO("Executed session commands:\n%s", sescmdstr.c_str()); + mxs::SSessionCommand& scmd = *it; + sescmdstr += scmd->to_string(); + sescmdstr += "\n"; } + + MXS_INFO("Executed session commands:\n%s", sescmdstr.c_str()); } } @@ -659,45 +655,38 @@ int32_t RWSplitSession::routeQuery(GWBUF* querybuf) { int rval = 0; - if (rses_closed) + if (query_queue == NULL && + (expected_responses == 0 || + mxs_mysql_get_command(querybuf) == MXS_COM_STMT_FETCH || + load_data_state == LOAD_DATA_ACTIVE || + large_query)) { - closed_session_reply(querybuf); + /** Gather the information required to make routing decisions */ + RouteInfo info(this, querybuf); + + /** No active or pending queries */ + if (route_single_stmt(querybuf, info)) + { + rval = 1; + } } else { - if (query_queue == NULL && - (expected_responses == 0 || - mxs_mysql_get_command(querybuf) == MXS_COM_STMT_FETCH || - load_data_state == LOAD_DATA_ACTIVE || - large_query)) - { - /** Gather the information required to make routing decisions */ - RouteInfo info(this, querybuf); + /** + * We are already processing a request from the client. Store the + * new query and wait for the previous one to complete. + */ + ss_dassert(expected_responses || query_queue); + MXS_INFO("Storing query (len: %d cmd: %0x), expecting %d replies to current command", + gwbuf_length(querybuf), GWBUF_DATA(querybuf)[4], expected_responses); + query_queue = gwbuf_append(query_queue, querybuf); + querybuf = NULL; + rval = 1; + ss_dassert(expected_responses > 0); - /** No active or pending queries */ - if (route_single_stmt(querybuf, info)) - { - rval = 1; - } - } - else + if (expected_responses == 0 && !route_stored_query()) { - /** - * We are already processing a request from the client. Store the - * new query and wait for the previous one to complete. - */ - ss_dassert(expected_responses || query_queue); - MXS_INFO("Storing query (len: %d cmd: %0x), expecting %d replies to current command", - gwbuf_length(querybuf), GWBUF_DATA(querybuf)[4], expected_responses); - query_queue = gwbuf_append(query_queue, querybuf); - querybuf = NULL; - rval = 1; - ss_dassert(expected_responses > 0); - - if (expected_responses == 0 && !route_stored_query()) - { - rval = 0; - } + rval = 0; } } @@ -913,7 +902,6 @@ void RWSplitSession::correct_packet_sequence(GWBUF *buffer) void RWSplitSession::clientReply(GWBUF *writebuf, DCB *backend_dcb) { DCB *client_dcb = backend_dcb->session->client_dcb; - ss_dassert(!rses_closed); SRWBackend& backend = get_backend_from_dcb(backend_dcb); @@ -1026,13 +1014,6 @@ void RWSplitSession::handleError(GWBUF *errmsgbuf, DCB *problem_dcb, { ss_dassert(problem_dcb->dcb_role == DCB_ROLE_BACKEND_HANDLER); CHK_DCB(problem_dcb); - - if (rses_closed) - { - *succp = false; - return; - } - MXS_SESSION *session = problem_dcb->session; ss_dassert(session); diff --git a/server/modules/routing/readwritesplit/rwsplitsession.cc b/server/modules/routing/readwritesplit/rwsplitsession.cc index f48d7fd1d..285cae01b 100644 --- a/server/modules/routing/readwritesplit/rwsplitsession.cc +++ b/server/modules/routing/readwritesplit/rwsplitsession.cc @@ -22,8 +22,6 @@ RWSplitSession::RWSplitSession(RWSplit* instance, MXS_SESSION* session, const SRWBackendList& backends, const SRWBackend& master): mxs::RouterSession(session), - rses_chk_top(CHK_NUM_ROUTER_SES), - rses_closed(false), backends(backends), current_master(master), large_query(false), @@ -41,8 +39,7 @@ RWSplitSession::RWSplitSession(RWSplit* instance, MXS_SESSION* session, recv_sescmd(0), gtid_pos(""), wait_gtid_state(EXPECTING_NOTHING), - next_seq(0), - rses_chk_tail(CHK_NUM_ROUTER_SES) + next_seq(0) { if (rses_config.rw_max_slave_conn_percent) { diff --git a/server/modules/routing/readwritesplit/rwsplitsession.hh b/server/modules/routing/readwritesplit/rwsplitsession.hh index 66b654bc7..c96340f0d 100644 --- a/server/modules/routing/readwritesplit/rwsplitsession.hh +++ b/server/modules/routing/readwritesplit/rwsplitsession.hh @@ -94,8 +94,6 @@ public: bool* pSuccess); // TODO: Make member variables private - skygw_chk_t rses_chk_top; - bool rses_closed; /**< true when closeSession is called */ mxs::SRWBackendList backends; /**< List of backend servers */ mxs::SRWBackend current_master; /**< Current master server */ mxs::SRWBackend target_node; /**< The currently locked target node */ @@ -123,7 +121,6 @@ public: std::string gtid_pos; /**< Gtid position for causal read */ wait_gtid_state_t wait_gtid_state; /**< Determine boundray of wait gtid result and client query result */ uint32_t next_seq; /**< Next packet'ssequence number */ - skygw_chk_t rses_chk_tail; private: RWSplitSession(RWSplit* instance, MXS_SESSION* session,