MXS-1722 Add better error messages to switchover_demote_master()
The error messages should now be a bit more reliable.
This commit is contained in:
@ -4052,7 +4052,7 @@ static bool switchover_demote_master(MYSQL_MONITOR* mon,
|
|||||||
bool success = false;
|
bool success = false;
|
||||||
bool query_error = false;
|
bool query_error = false;
|
||||||
MYSQL* conn = current_master->con;
|
MYSQL* conn = current_master->con;
|
||||||
const char* query = "";
|
const char* query = ""; // The next query to execute. Used also for error printing.
|
||||||
// The presence of an external master changes several things.
|
// The presence of an external master changes several things.
|
||||||
const bool external_master = SERVER_IS_SLAVE_OF_EXTERNAL_MASTER(current_master->server);
|
const bool external_master = SERVER_IS_SLAVE_OF_EXTERNAL_MASTER(current_master->server);
|
||||||
|
|
||||||
@ -4068,6 +4068,7 @@ static bool switchover_demote_master(MYSQL_MONITOR* mon,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool error_fetched = false;
|
||||||
string error_desc;
|
string error_desc;
|
||||||
if (!query_error)
|
if (!query_error)
|
||||||
{
|
{
|
||||||
@ -4101,27 +4102,39 @@ static bool switchover_demote_master(MYSQL_MONITOR* mon,
|
|||||||
{
|
{
|
||||||
// Somehow, a step after "SET read_only" failed. Try to set read_only back to 0. It may not
|
// Somehow, a step after "SET read_only" failed. Try to set read_only back to 0. It may not
|
||||||
// work since the connection is likely broken.
|
// work since the connection is likely broken.
|
||||||
error_desc = mysql_error(conn);
|
error_desc = mysql_error(conn); // Read connection error before next step.
|
||||||
|
error_fetched = true;
|
||||||
mxs_mysql_query(conn, "SET GLOBAL read_only=0;");
|
mxs_mysql_query(conn, "SET GLOBAL read_only=0;");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (query_error)
|
if (query_error && !error_fetched)
|
||||||
{
|
{
|
||||||
error_desc = mysql_error(conn);
|
error_desc = mysql_error(conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!success)
|
if (!success)
|
||||||
|
{
|
||||||
|
if (query_error)
|
||||||
{
|
{
|
||||||
if (error_desc.empty())
|
if (error_desc.empty())
|
||||||
{
|
{
|
||||||
PRINT_MXS_JSON_ERROR(err_out, "Demotion failed due to an error in updating gtid:s.");
|
const char UNKNOWN_ERROR[] = "Demotion failed due to an unknown error when executing "
|
||||||
|
"a query. Query: '%s'.";
|
||||||
|
PRINT_MXS_JSON_ERROR(err_out, UNKNOWN_ERROR, query);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PRINT_MXS_JSON_ERROR(err_out, "Demotion failed due to a query error: '%s'. Query: '%s'.",
|
const char KNOWN_ERROR[] = "Demotion failed due to a query error: '%s'. Query: '%s'.";
|
||||||
error_desc.c_str(), query);
|
PRINT_MXS_JSON_ERROR(err_out, KNOWN_ERROR, error_desc.c_str(), query);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const char GTID_ERROR[] = "Demotion failed due to an error in updating gtid:s. "
|
||||||
|
"Check log for more details.";
|
||||||
|
PRINT_MXS_JSON_ERROR(err_out, GTID_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return success;
|
return success;
|
||||||
|
|||||||
Reference in New Issue
Block a user