MXS-1503: Respect max_slave_connections
The slave selection now again respects max_slave_connections. This means that the amount of slave connections each session has will never grow beyond the configured value.
This commit is contained in:
@ -15,6 +15,7 @@
|
||||
#include "readwritesplit.hh"
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include <maxscale/query_classifier.h>
|
||||
#include <maxscale/protocol/mysql.h>
|
||||
@ -100,6 +101,17 @@ bool select_connect_backend_servers(RWSplit *inst, MXS_SESSION *session,
|
||||
int* expected_responses,
|
||||
connection_type type);
|
||||
SRWBackend get_root_master(const SRWBackendList& backends);
|
||||
|
||||
/**
|
||||
* Get total slave count and connected slave count
|
||||
*
|
||||
* @param backends List of backend servers
|
||||
* @param master Current master
|
||||
*
|
||||
* @return Total number of slaves and number of slaves we are connected to
|
||||
*/
|
||||
std::pair<int, int> get_slave_counts(SRWBackendList& backends, SRWBackend& master);
|
||||
|
||||
/*
|
||||
* The following are implemented in rwsplit_tmp_table_multi.c
|
||||
*/
|
||||
|
@ -389,6 +389,7 @@ SRWBackend get_hinted_backend(RWSplitSession *rses, char *name)
|
||||
SRWBackend get_slave_backend(RWSplitSession *rses, int max_rlag)
|
||||
{
|
||||
SRWBackend rval;
|
||||
auto counts = get_slave_counts(rses->backends, rses->current_master);
|
||||
|
||||
for (auto it = rses->backends.begin(); it != rses->backends.end(); it++)
|
||||
{
|
||||
@ -406,7 +407,7 @@ SRWBackend get_slave_backend(RWSplitSession *rses, int max_rlag)
|
||||
rval = backend;
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (backend->in_use() || counts.second < rses->router->max_slave_count())
|
||||
{
|
||||
if (!rses->rses_config.master_accept_reads && rval->is_master())
|
||||
{
|
||||
|
Reference in New Issue
Block a user