MXS-1856 Do not set read_only OFF if join_cluster() fails
This could in some cases leave read_only OFF even if the target slave begins replication.
This commit is contained in:
@ -4835,7 +4835,6 @@ static bool join_cluster(MXS_MONITORED_SERVER* server, const char* change_cmd)
|
|||||||
/* Server does not have slave connections. This operation can fail, or the resulting
|
/* Server does not have slave connections. This operation can fail, or the resulting
|
||||||
* replication may end up broken. */
|
* replication may end up broken. */
|
||||||
bool success = false;
|
bool success = false;
|
||||||
string error_msg;
|
|
||||||
const char* query = "SET GLOBAL read_only=1;";
|
const char* query = "SET GLOBAL read_only=1;";
|
||||||
if (mxs_mysql_query(server->con, query) == 0)
|
if (mxs_mysql_query(server->con, query) == 0)
|
||||||
{
|
{
|
||||||
@ -4849,23 +4848,12 @@ static bool join_cluster(MXS_MONITORED_SERVER* server, const char* change_cmd)
|
|||||||
MXS_NOTICE("Standalone server '%s' starting replication.", server->server->unique_name);
|
MXS_NOTICE("Standalone server '%s' starting replication.", server->server->unique_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!success)
|
|
||||||
{
|
|
||||||
// A step after "SET GLOBAL read_only=1" failed, try to undo. First, backup error message.
|
|
||||||
error_msg = mysql_error(server->con);
|
|
||||||
mxs_mysql_query(server->con, "SET GLOBAL read_only=0;");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!success)
|
if (!success)
|
||||||
{
|
{
|
||||||
if (error_msg.empty())
|
const char ERROR_MSG[] = "Standalone server '%s' failed to start replication: '%s'. Query: '%s'.";
|
||||||
{
|
MXS_WARNING(ERROR_MSG, server->server->unique_name, mysql_error(server->con), query);
|
||||||
error_msg = mysql_error(server->con);
|
|
||||||
}
|
|
||||||
MXS_WARNING("Standalone server '%s' failed to start replication: '%s'. Query: '%s'.",
|
|
||||||
server->server->unique_name, error_msg.c_str(), query);
|
|
||||||
}
|
}
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user