MXS-2167: Add support for extra_port
This allows MaxScale to connect to the server even when max_connections has been reached.
This commit is contained in:
@ -136,6 +136,7 @@ const char CN_PASSIVE[] = "passive";
|
||||
const char CN_PASSWORD[] = "password";
|
||||
const char CN_POLL_SLEEP[] = "poll_sleep";
|
||||
const char CN_PORT[] = "port";
|
||||
const char CN_EXTRA_PORT[] = "extra_port";
|
||||
const char CN_PROTOCOL[] = "protocol";
|
||||
const char CN_QUERY_CLASSIFIER[] = "query_classifier";
|
||||
const char CN_QUERY_CLASSIFIER_ARGS[] = "query_classifier_args";
|
||||
@ -402,6 +403,7 @@ const MXS_MODULE_PARAM config_server_params[] =
|
||||
{CN_PROTOCOL, MXS_MODULE_PARAM_STRING, NULL,
|
||||
MXS_MODULE_OPT_REQUIRED},
|
||||
{CN_PORT, MXS_MODULE_PARAM_COUNT, "3306"},
|
||||
{CN_EXTRA_PORT, MXS_MODULE_PARAM_COUNT, "0"},
|
||||
{CN_AUTHENTICATOR, MXS_MODULE_PARAM_STRING},
|
||||
{CN_MONITORUSER, MXS_MODULE_PARAM_STRING},
|
||||
{CN_MONITORPW, MXS_MODULE_PARAM_STRING},
|
||||
|
||||
@ -488,6 +488,10 @@ bool runtime_alter_server(SERVER* server, const char* key, const char* value)
|
||||
server_update_port(server, ival);
|
||||
}
|
||||
}
|
||||
else if (strcmp(key, CN_EXTRA_PORT) == 0)
|
||||
{
|
||||
server_update_extra_port(server, atoi(value));
|
||||
}
|
||||
else if (strcmp(key, CN_MONITORUSER) == 0)
|
||||
{
|
||||
server_update_credentials(server, value, server->monpw);
|
||||
|
||||
@ -30,6 +30,7 @@
|
||||
#include <maxscale/alloc.h>
|
||||
#include <maxscale/config.h>
|
||||
#include <maxscale/log.h>
|
||||
#include <maxbase/atomic.hh>
|
||||
|
||||
namespace
|
||||
{
|
||||
@ -191,6 +192,13 @@ MYSQL* mxs_mysql_real_connect(MYSQL* con, SERVER* server, const char* user, cons
|
||||
}
|
||||
|
||||
MYSQL* mysql = mysql_real_connect(con, server->address, user, passwd, NULL, server->port, NULL, 0);
|
||||
auto extra_port = mxb::atomic::load(&server->extra_port, mxb::atomic::RELAXED);
|
||||
|
||||
if (!mysql && extra_port)
|
||||
{
|
||||
mysql = mysql_real_connect(con, server->address, user, passwd, NULL, extra_port, NULL, 0);
|
||||
MXS_WARNING("Could not connect with normal port to server '%s', using extra_port", server->name);
|
||||
}
|
||||
|
||||
if (mysql)
|
||||
{
|
||||
|
||||
@ -154,6 +154,7 @@ SERVER* server_alloc(const char* name, MXS_CONFIG_PARAMETER* params)
|
||||
|
||||
server->name = my_name;
|
||||
server->port = config_get_integer(params, CN_PORT);
|
||||
server->extra_port = config_get_integer(params, CN_EXTRA_PORT);
|
||||
server->protocol = my_protocol;
|
||||
server->authenticator = my_authenticator;
|
||||
server->monuser[0] = '\0';
|
||||
@ -1034,6 +1035,18 @@ void server_update_port(SERVER* server, unsigned short port)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Update the extra_port value of a specific server
|
||||
*
|
||||
* @param server The server to update
|
||||
* @param port The new extra_port value
|
||||
*
|
||||
*/
|
||||
void server_update_extra_port(SERVER* server, unsigned short port)
|
||||
{
|
||||
mxb::atomic::store(&server->extra_port, port, mxb::atomic::RELAXED);
|
||||
}
|
||||
|
||||
static struct
|
||||
{
|
||||
const char* str;
|
||||
|
||||
Reference in New Issue
Block a user