SlaveStatus::to_short_string() uses member field
The owner server name is now stored in a field.
This commit is contained in:
@ -877,8 +877,7 @@ void MariaDBMonitor::wait_cluster_stabilization(ClusterOperation& op, const Serv
|
|||||||
{
|
{
|
||||||
// IO error on slave
|
// IO error on slave
|
||||||
MXS_WARNING("%s cannot start replication because of IO thread error: '%s'.",
|
MXS_WARNING("%s cannot start replication because of IO thread error: '%s'.",
|
||||||
slave_conn->to_short_string(slave->name()).c_str(),
|
slave_conn->to_short_string().c_str(), slave_conn->last_error.c_str());
|
||||||
slave_conn->last_error.c_str());
|
|
||||||
repl_fails.push_back(*iter);
|
repl_fails.push_back(*iter);
|
||||||
iter = unconfirmed.erase(iter);
|
iter = unconfirmed.erase(iter);
|
||||||
}
|
}
|
||||||
@ -886,8 +885,7 @@ void MariaDBMonitor::wait_cluster_stabilization(ClusterOperation& op, const Serv
|
|||||||
{
|
{
|
||||||
// SQL error on slave
|
// SQL error on slave
|
||||||
MXS_WARNING("%s cannot start replication because of SQL thread error: '%s'.",
|
MXS_WARNING("%s cannot start replication because of SQL thread error: '%s'.",
|
||||||
slave_conn->to_short_string(slave->name()).c_str(),
|
slave_conn->to_short_string().c_str(), slave_conn->last_error.c_str());
|
||||||
slave_conn->last_error.c_str());
|
|
||||||
repl_fails.push_back(*iter);
|
repl_fails.push_back(*iter);
|
||||||
iter = unconfirmed.erase(iter);
|
iter = unconfirmed.erase(iter);
|
||||||
}
|
}
|
||||||
@ -1394,7 +1392,7 @@ void MariaDBMonitor::check_cluster_operations_support()
|
|||||||
{
|
{
|
||||||
supported = false;
|
supported = false;
|
||||||
auto reason = string_printf("%s is not using gtid-replication.",
|
auto reason = string_printf("%s is not using gtid-replication.",
|
||||||
slave_conn.to_short_string(server->name()).c_str());
|
slave_conn.to_short_string().c_str());
|
||||||
printer.cat(all_reasons, reason);
|
printer.cat(all_reasons, reason);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -291,6 +291,7 @@ bool MariaDBServer::do_show_slave_status(string* errmsg_out)
|
|||||||
while (result->next_row())
|
while (result->next_row())
|
||||||
{
|
{
|
||||||
SlaveStatus new_row;
|
SlaveStatus new_row;
|
||||||
|
new_row.owning_server = name();
|
||||||
new_row.master_host = result->get_string(i_master_host);
|
new_row.master_host = result->get_string(i_master_host);
|
||||||
new_row.master_port = result->get_uint(i_master_port);
|
new_row.master_port = result->get_uint(i_master_port);
|
||||||
string last_io_error = result->get_string(i_last_io_error);
|
string last_io_error = result->get_string(i_last_io_error);
|
||||||
@ -1916,8 +1917,7 @@ bool MariaDBServer::merge_slave_conns(ClusterOperation& op, const SlaveStatusArr
|
|||||||
if (conn_can_be_merged(slave_conn, &ignore_reason))
|
if (conn_can_be_merged(slave_conn, &ignore_reason))
|
||||||
{
|
{
|
||||||
MXS_WARNING("%s was ignored when promoting %s because %s",
|
MXS_WARNING("%s was ignored when promoting %s because %s",
|
||||||
slave_conn.to_short_string(op.demotion_target->name()).c_str(), name(),
|
slave_conn.to_short_string().c_str(), name(), ignore_reason.c_str());
|
||||||
ignore_reason.c_str());
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1968,9 +1968,7 @@ bool MariaDBServer::copy_slave_conns(ClusterOperation& op, const SlaveStatusArra
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
MXS_WARNING("%s was not copied to %s because %s",
|
MXS_WARNING("%s was not copied to %s because %s",
|
||||||
slave_conn.to_short_string(replacement->name()).c_str(),
|
slave_conn.to_short_string().c_str(), name(), reason_not_copied.c_str());
|
||||||
name(),
|
|
||||||
reason_not_copied.c_str());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return !start_slave_error;
|
return !start_slave_error;
|
||||||
@ -1988,30 +1986,32 @@ bool MariaDBServer::create_start_slave(ClusterOperation& op, const SlaveStatus&
|
|||||||
StopWatch timer;
|
StopWatch timer;
|
||||||
string error_msg;
|
string error_msg;
|
||||||
bool success = false;
|
bool success = false;
|
||||||
string change_master = generate_change_master_cmd(op, slave_conn);
|
SlaveStatus new_conn = slave_conn;
|
||||||
|
new_conn.owning_server = name();
|
||||||
|
string change_master = generate_change_master_cmd(op, new_conn);
|
||||||
bool conn_created = execute_cmd_time_limit(change_master, op.time_remaining, &error_msg);
|
bool conn_created = execute_cmd_time_limit(change_master, op.time_remaining, &error_msg);
|
||||||
op.time_remaining -= timer.restart();
|
op.time_remaining -= timer.restart();
|
||||||
if (conn_created)
|
if (conn_created)
|
||||||
{
|
{
|
||||||
string start_slave = string_printf("START SLAVE '%s';", slave_conn.name.c_str());
|
string start_slave = string_printf("START SLAVE '%s';", new_conn.name.c_str());
|
||||||
bool slave_started = execute_cmd_time_limit(start_slave, op.time_remaining, &error_msg);
|
bool slave_started = execute_cmd_time_limit(start_slave, op.time_remaining, &error_msg);
|
||||||
op.time_remaining -= timer.restart();
|
op.time_remaining -= timer.restart();
|
||||||
if (slave_started)
|
if (slave_started)
|
||||||
{
|
{
|
||||||
success = true;
|
success = true;
|
||||||
MXS_NOTICE("%s created and started.", slave_conn.to_short_string(name()).c_str());
|
MXS_NOTICE("%s created and started.", new_conn.to_short_string().c_str());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MXS_ERROR("%s could not be started: %s",
|
MXS_ERROR("%s could not be started: %s",
|
||||||
slave_conn.to_short_string(name()).c_str(), error_msg.c_str());
|
new_conn.to_short_string().c_str(), error_msg.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// TODO: This may currently print out passwords.
|
// TODO: This may currently print out passwords.
|
||||||
MXS_ERROR("%s could not be created: %s",
|
MXS_ERROR("%s could not be created: %s",
|
||||||
slave_conn.to_short_string(name()).c_str(), error_msg.c_str());
|
new_conn.to_short_string().c_str(), error_msg.c_str());
|
||||||
}
|
}
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
@ -2076,8 +2076,7 @@ bool MariaDBServer::redirect_existing_slave_conn(ClusterOperation& op)
|
|||||||
{
|
{
|
||||||
PRINT_MXS_JSON_ERROR(op.error_out,
|
PRINT_MXS_JSON_ERROR(op.error_out,
|
||||||
"%s could not be started: %s",
|
"%s could not be started: %s",
|
||||||
modified_conn.to_short_string(name()).c_str(),
|
modified_conn.to_short_string().c_str(), error_msg.c_str());
|
||||||
error_msg.c_str());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -2085,7 +2084,7 @@ bool MariaDBServer::redirect_existing_slave_conn(ClusterOperation& op)
|
|||||||
// TODO: This may currently print out passwords.
|
// TODO: This may currently print out passwords.
|
||||||
PRINT_MXS_JSON_ERROR(op.error_out,
|
PRINT_MXS_JSON_ERROR(op.error_out,
|
||||||
"%s could not be redirected to [%s]:%i: %s",
|
"%s could not be redirected to [%s]:%i: %s",
|
||||||
old_conn->to_short_string(name()).c_str(),
|
old_conn->to_short_string().c_str(),
|
||||||
modified_conn.master_host.c_str(), modified_conn.master_port,
|
modified_conn.master_host.c_str(), modified_conn.master_port,
|
||||||
error_msg.c_str());
|
error_msg.c_str());
|
||||||
}
|
}
|
||||||
|
@ -49,17 +49,17 @@ string SlaveStatus::to_string() const
|
|||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
string SlaveStatus::to_short_string(const string& owner) const
|
string SlaveStatus::to_short_string() const
|
||||||
{
|
{
|
||||||
if (name.empty())
|
if (name.empty())
|
||||||
{
|
{
|
||||||
return string_printf("Slave connection from %s to [%s]:%i",
|
return string_printf("Slave connection from %s to [%s]:%i",
|
||||||
owner.c_str(), master_host.c_str(), master_port);
|
owning_server.c_str(), master_host.c_str(), master_port);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return string_printf("Slave connection '%s' from %s to [%s]:%i",
|
return string_printf("Slave connection '%s' from %s to [%s]:%i",
|
||||||
name.c_str(), owner.c_str(), master_host.c_str(), master_port);
|
name.c_str(), owning_server.c_str(), master_host.c_str(), master_port);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,9 +170,10 @@ public:
|
|||||||
SLAVE_IO_NO,
|
SLAVE_IO_NO,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
std::string owning_server; /* Server name of the owner */
|
||||||
bool seen_connected = false; /* Has this slave connection been seen connected,
|
bool seen_connected = false; /* Has this slave connection been seen connected,
|
||||||
* meaning that the master server id is correct?
|
* meaning that the master server id
|
||||||
**/
|
* is correct? */
|
||||||
std::string name; /* Slave connection name. Must be unique for
|
std::string name; /* Slave connection name. Must be unique for
|
||||||
* the server.*/
|
* the server.*/
|
||||||
int64_t master_server_id = SERVER_ID_UNKNOWN; /* The master's server_id value. Valid ids are
|
int64_t master_server_id = SERVER_ID_UNKNOWN; /* The master's server_id value. Valid ids are
|
||||||
@ -195,7 +196,14 @@ public:
|
|||||||
|
|
||||||
std::string to_string() const;
|
std::string to_string() const;
|
||||||
json_t* to_json() const;
|
json_t* to_json() const;
|
||||||
std::string to_short_string(const std::string& owner) const;
|
|
||||||
|
/**
|
||||||
|
* Create a short description in the form of "Slave connection from <slave> to <master>"
|
||||||
|
*
|
||||||
|
* @return Description
|
||||||
|
*/
|
||||||
|
std::string to_short_string() const;
|
||||||
|
|
||||||
static slave_io_running_t slave_io_from_string(const std::string& str);
|
static slave_io_running_t slave_io_from_string(const std::string& str);
|
||||||
static std::string slave_io_to_string(slave_io_running_t slave_io);
|
static std::string slave_io_to_string(slave_io_running_t slave_io);
|
||||||
bool should_be_copied(std::string* ignore_reason_out) const;
|
bool should_be_copied(std::string* ignore_reason_out) const;
|
||||||
|
Reference in New Issue
Block a user