MXS-1625 large_query flag moved from RWS session to query classifier

This commit is contained in:
Johan Wikman
2018-04-04 14:40:07 +03:00
parent bc22790e1b
commit c08120846c
7 changed files with 22 additions and 6 deletions

View File

@ -66,6 +66,16 @@ public:
m_have_tmp_tables = have_tmp_tables; m_have_tmp_tables = have_tmp_tables;
} }
bool large_query() const
{
return m_large_query;
}
void set_large_query(bool large_query)
{
m_large_query = large_query;
}
uint32_t get_route_target(uint8_t command, uint32_t qtype); uint32_t get_route_target(uint8_t command, uint32_t qtype);
private: private:
@ -73,6 +83,7 @@ private:
mxs_target_t m_use_sql_variables_in; mxs_target_t m_use_sql_variables_in;
load_data_state_t m_load_data_state; load_data_state_t m_load_data_state;
bool m_have_tmp_tables; bool m_have_tmp_tables;
bool m_large_query; /**< Set to true when processing payloads >= 2^24 bytes */
}; };
} }

View File

@ -24,6 +24,7 @@ QueryClassifier::QueryClassifier(MXS_SESSION* pSession,
, m_use_sql_variables_in(use_sql_variables_in) , m_use_sql_variables_in(use_sql_variables_in)
, m_load_data_state(LOAD_DATA_INACTIVE) , m_load_data_state(LOAD_DATA_INACTIVE)
, m_have_tmp_tables(false) , m_have_tmp_tables(false)
, m_large_query(false)
{ {
} }

View File

@ -347,7 +347,7 @@ int32_t RWSplitSession::routeQuery(GWBUF* querybuf)
(expected_responses == 0 || (expected_responses == 0 ||
mxs_mysql_get_command(querybuf) == MXS_COM_STMT_FETCH || mxs_mysql_get_command(querybuf) == MXS_COM_STMT_FETCH ||
m_qc.load_data_state() == QueryClassifier::LOAD_DATA_ACTIVE || m_qc.load_data_state() == QueryClassifier::LOAD_DATA_ACTIVE ||
large_query)) m_qc.large_query()))
{ {
/** Gather the information required to make routing decisions */ /** Gather the information required to make routing decisions */
RouteInfo info(this, querybuf); RouteInfo info(this, querybuf);

View File

@ -108,7 +108,7 @@ route_target_t get_route_target(mxs::QueryClassifier& qc,
void void
log_transaction_status(RWSplitSession *rses, GWBUF *querybuf, uint32_t qtype) log_transaction_status(RWSplitSession *rses, GWBUF *querybuf, uint32_t qtype)
{ {
if (rses->m_large_query) if (rses->qc().large_query())
{ {
MXS_INFO("> Processing large request with more than 2^24 bytes of data"); MXS_INFO("> Processing large request with more than 2^24 bytes of data");
} }

View File

@ -164,7 +164,7 @@ bool RWSplitSession::route_single_stmt(GWBUF *querybuf, const RouteInfo& info)
{ {
bool store_stmt = false; bool store_stmt = false;
if (m_large_query) if (m_qc.large_query())
{ {
/** We're processing a large query that's split across multiple packets. /** We're processing a large query that's split across multiple packets.
* Route it to the same backend where we routed the previous packet. */ * Route it to the same backend where we routed the previous packet. */
@ -975,7 +975,9 @@ bool RWSplitSession::handle_got_target(GWBUF* querybuf, SRWBackend& target, bool
} }
} }
if ((this->m_large_query = large_query)) m_qc.set_large_query(large_query);
if (large_query)
{ {
/** Store the previous target as we're processing a multi-packet query */ /** Store the previous target as we're processing a multi-packet query */
m_prev_target = target; m_prev_target = target;

View File

@ -24,7 +24,6 @@ RWSplitSession::RWSplitSession(RWSplit* instance, MXS_SESSION* session,
mxs::RouterSession(session), mxs::RouterSession(session),
m_backends(backends), m_backends(backends),
m_current_master(master), m_current_master(master),
m_large_query(false),
m_config(instance->config()), m_config(instance->config()),
m_nbackends(instance->service()->n_dbref), m_nbackends(instance->service()->n_dbref),
m_load_data_sent(0), m_load_data_sent(0),

View File

@ -104,7 +104,6 @@ public:
mxs::SRWBackend m_current_master; /**< Current master server */ mxs::SRWBackend m_current_master; /**< Current master server */
mxs::SRWBackend m_target_node; /**< The currently locked target node */ mxs::SRWBackend m_target_node; /**< The currently locked target node */
mxs::SRWBackend m_prev_target; /**< The previous target where a query was sent */ mxs::SRWBackend m_prev_target; /**< The previous target where a query was sent */
bool m_large_query; /**< Set to true when processing payloads >= 2^24 bytes */
Config m_config; /**< copied config info from router instance */ Config m_config; /**< copied config info from router instance */
int m_nbackends; /**< Number of backend servers (obsolete) */ int m_nbackends; /**< Number of backend servers (obsolete) */
uint64_t m_load_data_sent; /**< How much data has been sent */ uint64_t m_load_data_sent; /**< How much data has been sent */
@ -175,7 +174,11 @@ private:
*/ */
inline bool locked_to_master() const inline bool locked_to_master() const
{ {
<<<<<<< bc22790e1bde96fc6a16b8c719805b9d3dd193b5
return m_large_query || (m_current_master && m_target_node == m_current_master); return m_large_query || (m_current_master && m_target_node == m_current_master);
=======
return m_qc.large_query() || (current_master && target_node == current_master);
>>>>>>> MXS-1625 large_query flag moved from RWS session to query classifier
} }
}; };