Allow switchover for arbitrary topologies
The demoted server no longer needs to be the master.
This commit is contained in:
@ -1505,7 +1505,7 @@ unique_ptr<ClusterOperation> MariaDBMonitor::switchover_prepare(SERVER* promotio
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Autoselect current master as demotion target.
|
// Autoselect current master as demotion target.
|
||||||
if (m_master == NULL)
|
if (m_master == NULL || !m_master->is_master())
|
||||||
{
|
{
|
||||||
const char msg[] = "Can not autoselect a demotion target for switchover: cluster does "
|
const char msg[] = "Can not autoselect a demotion target for switchover: cluster does "
|
||||||
"not have a master.";
|
"not have a master.";
|
||||||
|
|||||||
@ -1058,10 +1058,9 @@ bool MariaDBServer::can_be_demoted_switchover(string* reason_out)
|
|||||||
string reason;
|
string reason;
|
||||||
string query_error;
|
string query_error;
|
||||||
|
|
||||||
// TODO: Add relay server support
|
if (!is_usable())
|
||||||
if (!is_master())
|
|
||||||
{
|
{
|
||||||
reason = "it is not the current master or it is in maintenance.";
|
reason = "it is not running or it is in maintenance.";
|
||||||
}
|
}
|
||||||
else if (!update_replication_settings(&query_error))
|
else if (!update_replication_settings(&query_error))
|
||||||
{
|
{
|
||||||
@ -1071,6 +1070,12 @@ bool MariaDBServer::can_be_demoted_switchover(string* reason_out)
|
|||||||
{
|
{
|
||||||
reason = "its binary log is disabled.";
|
reason = "its binary log is disabled.";
|
||||||
}
|
}
|
||||||
|
else if (!is_master() && !m_rpl_settings.log_slave_updates)
|
||||||
|
{
|
||||||
|
// This means that gtid_binlog_pos cannot be trusted.
|
||||||
|
// TODO: reduce dependency on gtid_binlog_pos to get rid of this requirement
|
||||||
|
reason = "it is not the master and log_slave_updates is disabled.";
|
||||||
|
}
|
||||||
else if (m_gtid_binlog_pos.empty())
|
else if (m_gtid_binlog_pos.empty())
|
||||||
{
|
{
|
||||||
reason = "it does not have a 'gtid_binlog_pos'.";
|
reason = "it does not have a 'gtid_binlog_pos'.";
|
||||||
|
|||||||
Reference in New Issue
Block a user