Merge branch '2.1' into develop
This commit is contained in:
@ -46,13 +46,15 @@ struct Config
|
||||
pcre2_code* ignore_regex; /**< Regular expression used to ignore databases */
|
||||
pcre2_match_data* ignore_match_data; /**< Match data for @c ignore_regex */
|
||||
std::set<std::string> ignored_dbs; /**< Set of ignored databases */
|
||||
SERVER* preferred_server; /**< Server to prefer in conflict situations */
|
||||
|
||||
Config():
|
||||
refresh_min_interval(0.0),
|
||||
refresh_databases(false),
|
||||
debug(false),
|
||||
ignore_regex(NULL),
|
||||
ignore_match_data(NULL)
|
||||
ignore_match_data(NULL),
|
||||
preferred_server(NULL)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
@ -75,6 +75,7 @@ SchemaRouter* SchemaRouter::create(SERVICE* pService, char** pzOptions)
|
||||
config.refresh_databases = config_get_bool(conf, "refresh_databases");
|
||||
config.refresh_min_interval = config_get_integer(conf, "refresh_interval");
|
||||
config.debug = config_get_bool(conf, "debug");
|
||||
config.preferred_server = config_get_server(conf, "preferred_server");
|
||||
|
||||
/** Add default system databases to ignore */
|
||||
config.ignored_dbs.insert("mysql");
|
||||
@ -401,6 +402,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
||||
{"refresh_databases", MXS_MODULE_PARAM_BOOL, "true"},
|
||||
{"refresh_interval", MXS_MODULE_PARAM_COUNT, DEFAULT_REFRESH_INTERVAL},
|
||||
{"debug", MXS_MODULE_PARAM_BOOL, "false"},
|
||||
{"preferred_server", MXS_MODULE_PARAM_SERVER},
|
||||
{MXS_END_MODULE_PARAMS}
|
||||
}
|
||||
};
|
||||
|
@ -1322,6 +1322,14 @@ enum showdb_response SchemaRouterSession::parse_mapping_response(SSRBackend& bre
|
||||
data, target->unique_name, duplicate->unique_name,
|
||||
m_client->user, m_client->remote);
|
||||
}
|
||||
else if (m_config->preferred_server == target)
|
||||
{
|
||||
/** In conflict situations, use the preferred server */
|
||||
MXS_INFO("Forcing location of '%s' from '%s' to '%s'",
|
||||
data, m_shard.get_location(data)->unique_name,
|
||||
target->unique_name);
|
||||
m_shard.replace_location(data, target);
|
||||
}
|
||||
}
|
||||
MXS_FREE(data);
|
||||
}
|
||||
|
@ -32,6 +32,12 @@ bool Shard::add_location(std::string db, SERVER* target)
|
||||
return m_map.insert(std::make_pair(db, target)).second;
|
||||
}
|
||||
|
||||
void Shard::replace_location(std::string db, SERVER* target)
|
||||
{
|
||||
std::transform(db.begin(), db.end(), db.begin(), ::tolower);
|
||||
m_map[db] = target;
|
||||
}
|
||||
|
||||
SERVER* Shard::get_location(std::string db)
|
||||
{
|
||||
SERVER* rval = NULL;
|
||||
|
@ -52,6 +52,14 @@ public:
|
||||
*/
|
||||
SERVER* get_location(std::string db);
|
||||
|
||||
/**
|
||||
* @brief Change the location of a database
|
||||
*
|
||||
* @param db Database to relocate
|
||||
* @param target Target where database is relocated to
|
||||
*/
|
||||
void replace_location(std::string db, SERVER* target);
|
||||
|
||||
/**
|
||||
* @brief Check if shard contains stale information
|
||||
*
|
||||
|
Reference in New Issue
Block a user