MXS-1777: Initial version of routing based on query response time.

The main piece of code, slave selection (backend_cmp_response_time), uses the available
method of pair-wise comparison of slaves. This will be changed to selection using all
available slaves, along with removal of hard coded values.
This commit is contained in:
Niclas Antti
2018-07-27 13:07:18 +03:00
parent 1e6509423a
commit 6351ab9c73
10 changed files with 250 additions and 10 deletions

View File

@ -97,6 +97,18 @@ void RWSplitSession::close()
{
close_all_connections(m_backends);
m_current_query.reset();
for (auto& backend : m_backends)
{
const ResponseStat& stat = backend->response_stat();
if (stat.is_valid())
{
server_add_response_average(backend->server(),
stat.average().secs(), stat.num_samples());
}
backend->response_stat().reset();
}
}
int32_t RWSplitSession::routeQuery(GWBUF* querybuf)
@ -613,6 +625,16 @@ void RWSplitSession::clientReply(GWBUF *writebuf, DCB *backend_dcb)
m_can_replay_trx = true;
}
ResponseStat& stat = backend->response_stat();
stat.query_ended();
if (stat.is_valid() && stat.sync_time_reached(500)) // nantti, TODO
{
server_add_response_average(backend->server(),
stat.average().secs(), stat.num_samples());
stat.reset();
}
if (backend->in_use() && backend->has_session_commands())
{
// Backend is still in use and has more session commands to execute