Partially revert 4ba011266843857bbd3201e5b925a47e88e1808f
Add back leading operator enforcement.
This commit is contained in:
@ -137,12 +137,12 @@ void GaleraMonitor::update_server_status(MXS_MONITORED_SERVER* monitored_server)
|
||||
server_string = monitored_server->server->version_string;
|
||||
|
||||
/* Check if the the Galera FSM shows this node is joined to the cluster */
|
||||
const char* cluster_member
|
||||
= "SHOW STATUS WHERE Variable_name IN"
|
||||
" ('wsrep_cluster_state_uuid',"
|
||||
" 'wsrep_cluster_size',"
|
||||
" 'wsrep_local_index',"
|
||||
" 'wsrep_local_state')";
|
||||
const char* cluster_member =
|
||||
"SHOW STATUS WHERE Variable_name IN"
|
||||
" ('wsrep_cluster_state_uuid',"
|
||||
" 'wsrep_cluster_size',"
|
||||
" 'wsrep_local_index',"
|
||||
" 'wsrep_local_state')";
|
||||
|
||||
if (mxs_mysql_query(monitored_server->con, cluster_member) == 0
|
||||
&& (result = mysql_store_result(monitored_server->con)) != NULL)
|
||||
|
@ -57,9 +57,9 @@ static bool is_master(MXS_MONITORED_SERVER* server)
|
||||
{
|
||||
bool rval = false;
|
||||
MYSQL_RES* result;
|
||||
const char* master_query
|
||||
= "SELECT VARIABLE_VALUE, @@server_uuid, @@read_only FROM performance_schema.global_status "
|
||||
"WHERE VARIABLE_NAME= 'group_replication_primary_member'";
|
||||
const char* master_query =
|
||||
"SELECT VARIABLE_VALUE, @@server_uuid, @@read_only FROM performance_schema.global_status "
|
||||
"WHERE VARIABLE_NAME= 'group_replication_primary_member'";
|
||||
|
||||
if (mysql_query(server->con, master_query) == 0 && (result = mysql_store_result(server->con)))
|
||||
{
|
||||
|
@ -41,21 +41,21 @@ void topology_DFS(MariaDBServer* root, VisitorFunc& visitor)
|
||||
{
|
||||
int next_index = NodeData::INDEX_FIRST;
|
||||
// This lambda is recursive, so its type needs to be defined and it needs to "capture itself".
|
||||
std::function<void(MariaDBServer*, VisitorFunc&)> topology_DFS_visit
|
||||
= [&topology_DFS_visit, &next_index](MariaDBServer* node, VisitorFunc& visitor) {
|
||||
mxb_assert(node->m_node.index == NodeData::INDEX_NOT_VISITED);
|
||||
node->m_node.index = next_index++;
|
||||
if (visitor(node))
|
||||
std::function<void(MariaDBServer*, VisitorFunc&)> topology_DFS_visit =
|
||||
[&topology_DFS_visit, &next_index](MariaDBServer* node, VisitorFunc& visitor) {
|
||||
mxb_assert(node->m_node.index == NodeData::INDEX_NOT_VISITED);
|
||||
node->m_node.index = next_index++;
|
||||
if (visitor(node))
|
||||
{
|
||||
for (MariaDBServer* slave : node->m_node.children)
|
||||
{
|
||||
for (MariaDBServer* slave : node->m_node.children)
|
||||
if (slave->m_node.index == NodeData::INDEX_NOT_VISITED)
|
||||
{
|
||||
if (slave->m_node.index == NodeData::INDEX_NOT_VISITED)
|
||||
{
|
||||
topology_DFS_visit(slave, visitor);
|
||||
}
|
||||
topology_DFS_visit(slave, visitor);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
topology_DFS_visit(root, visitor);
|
||||
}
|
||||
|
@ -1624,11 +1624,11 @@ void MariaDBMonitor::check_cluster_operations_support()
|
||||
|
||||
if (!supported)
|
||||
{
|
||||
const char PROBLEMS[]
|
||||
= "The backend cluster does not support failover/switchover due to the following reason(s):\n"
|
||||
"%s\n"
|
||||
"Automatic failover/switchover has been disabled. They should only be enabled "
|
||||
"after the above issues have been resolved.";
|
||||
const char PROBLEMS[] =
|
||||
"The backend cluster does not support failover/switchover due to the following reason(s):\n"
|
||||
"%s\n"
|
||||
"Automatic failover/switchover has been disabled. They should only be enabled "
|
||||
"after the above issues have been resolved.";
|
||||
string p1 = string_printf(PROBLEMS, all_reasons.c_str());
|
||||
string p2 = string_printf(RE_ENABLE_FMT, "failover", CN_AUTO_FAILOVER, m_monitor->name);
|
||||
string p3 = string_printf(RE_ENABLE_FMT,
|
||||
@ -1739,8 +1739,8 @@ bool MariaDBMonitor::switchover_prepare(SERVER* promotion_server,
|
||||
const auto op = ClusterOperation::SWITCHOVER;
|
||||
// Check that both servers are ok if specified, or autoselect them. Demotion target must be checked
|
||||
// first since the promotion target depends on it.
|
||||
mxb_assert(promotion_target_out && demotion_target_out &&
|
||||
!*promotion_target_out && !*demotion_target_out);
|
||||
mxb_assert(promotion_target_out && demotion_target_out
|
||||
&& !*promotion_target_out && !*demotion_target_out);
|
||||
|
||||
MariaDBServer* demotion_target = NULL;
|
||||
string demotion_msg;
|
||||
|
@ -281,11 +281,11 @@ string MariaDBMonitor::diagnostics_to_string() const
|
||||
rval += string_printf("Switchover timeout: %u\n", m_switchover_timeout);
|
||||
rval += string_printf("Automatic rejoin: %s\n", m_auto_rejoin ? "Enabled" : "Disabled");
|
||||
rval += string_printf("Enforce read-only: %s\n",
|
||||
m_enforce_read_only_slaves
|
||||
? "Enabled" : "Disabled");
|
||||
m_enforce_read_only_slaves ?
|
||||
"Enabled" : "Disabled");
|
||||
rval += string_printf("Detect stale master: %s\n",
|
||||
(m_detect_stale_master == 1)
|
||||
? "Enabled" : "Disabled");
|
||||
(m_detect_stale_master == 1) ?
|
||||
"Enabled" : "Disabled");
|
||||
if (m_excluded_servers.size() > 0)
|
||||
{
|
||||
rval += string_printf("Non-promotable servers (failover): ");
|
||||
@ -323,8 +323,8 @@ json_t* MariaDBMonitor::to_json() const
|
||||
json_object_set_new(rval, "master", m_master == NULL ? json_null() : json_string(m_master->name()));
|
||||
json_object_set_new(rval,
|
||||
"master_gtid_domain_id",
|
||||
m_master_gtid_domain == GTID_DOMAIN_UNKNOWN ? json_null()
|
||||
: json_integer(m_master_gtid_domain));
|
||||
m_master_gtid_domain == GTID_DOMAIN_UNKNOWN ? json_null() :
|
||||
json_integer(m_master_gtid_domain));
|
||||
|
||||
json_t* server_info = json_array();
|
||||
for (MariaDBServer* server : m_servers)
|
||||
@ -606,8 +606,8 @@ void MariaDBMonitor::update_external_master()
|
||||
mxb_assert(!m_master->m_slave_status.empty() && !m_master->m_node.external_masters.empty());
|
||||
// TODO: Add support for multiple external masters.
|
||||
auto& master_sstatus = m_master->m_slave_status[0];
|
||||
if (master_sstatus.master_host != m_external_master_host ||
|
||||
master_sstatus.master_port != m_external_master_port)
|
||||
if (master_sstatus.master_host != m_external_master_host
|
||||
|| master_sstatus.master_port != m_external_master_port)
|
||||
{
|
||||
const string new_ext_host = master_sstatus.master_host;
|
||||
const int new_ext_port = master_sstatus.master_port;
|
||||
@ -795,10 +795,10 @@ bool MariaDBMonitor::run_manual_switchover(SERVER* promotion_server,
|
||||
{
|
||||
bool rval = false;
|
||||
bool send_ok = execute_manual_command([this, &rval, promotion_server, demotion_server, error_out]() {
|
||||
rval
|
||||
= manual_switchover(promotion_server,
|
||||
demotion_server,
|
||||
error_out);
|
||||
rval =
|
||||
manual_switchover(promotion_server,
|
||||
demotion_server,
|
||||
error_out);
|
||||
},
|
||||
error_out);
|
||||
return send_ok && rval;
|
||||
|
@ -223,15 +223,15 @@ bool MariaDBServer::do_show_slave_status(string* errmsg_out)
|
||||
string last_sql_error = result->get_string(i_last_sql_error);
|
||||
new_row.last_error = !last_io_error.empty() ? last_io_error : last_sql_error;
|
||||
|
||||
new_row.slave_io_running
|
||||
= SlaveStatus::slave_io_from_string(result->get_string(i_slave_io_running));
|
||||
new_row.slave_io_running =
|
||||
SlaveStatus::slave_io_from_string(result->get_string(i_slave_io_running));
|
||||
new_row.slave_sql_running = (result->get_string(i_slave_sql_running) == "Yes");
|
||||
new_row.master_server_id = result->get_uint(i_master_server_id);
|
||||
|
||||
auto rlag = result->get_uint(i_seconds_behind_master);
|
||||
// If slave connection is stopped, the value given by the backend is null -> -1.
|
||||
new_row.seconds_behind_master = (rlag < 0) ? MXS_RLAG_UNDEFINED
|
||||
: (rlag > INT_MAX) ? INT_MAX : rlag;
|
||||
new_row.seconds_behind_master = (rlag < 0) ? MXS_RLAG_UNDEFINED :
|
||||
(rlag > INT_MAX) ? INT_MAX : rlag;
|
||||
|
||||
if (all_slaves_status)
|
||||
{
|
||||
@ -409,16 +409,16 @@ void MariaDBServer::warn_replication_settings() const
|
||||
const char* servername = name();
|
||||
if (m_rpl_settings.gtid_strict_mode == false)
|
||||
{
|
||||
const char NO_STRICT[]
|
||||
= "Slave '%s' has gtid_strict_mode disabled. Enabling this setting is recommended. "
|
||||
"For more information, see https://mariadb.com/kb/en/library/gtid/#gtid_strict_mode";
|
||||
const char NO_STRICT[] =
|
||||
"Slave '%s' has gtid_strict_mode disabled. Enabling this setting is recommended. "
|
||||
"For more information, see https://mariadb.com/kb/en/library/gtid/#gtid_strict_mode";
|
||||
MXS_WARNING(NO_STRICT, servername);
|
||||
}
|
||||
if (m_rpl_settings.log_slave_updates == false)
|
||||
{
|
||||
const char NO_SLAVE_UPDATES[]
|
||||
= "Slave '%s' has log_slave_updates disabled. It is a valid candidate but replication "
|
||||
"will break for lagging slaves if '%s' is promoted.";
|
||||
const char NO_SLAVE_UPDATES[] =
|
||||
"Slave '%s' has log_slave_updates disabled. It is a valid candidate but replication "
|
||||
"will break for lagging slaves if '%s' is promoted.";
|
||||
MXS_WARNING(NO_SLAVE_UPDATES, servername, servername);
|
||||
}
|
||||
}
|
||||
@ -580,13 +580,13 @@ json_t* MariaDBServer::to_json() const
|
||||
|
||||
json_object_set_new(result,
|
||||
"gtid_current_pos",
|
||||
m_gtid_current_pos.empty() ? json_null()
|
||||
: json_string(m_gtid_current_pos.to_string().c_str()));
|
||||
m_gtid_current_pos.empty() ? json_null() :
|
||||
json_string(m_gtid_current_pos.to_string().c_str()));
|
||||
|
||||
json_object_set_new(result,
|
||||
"gtid_binlog_pos",
|
||||
m_gtid_binlog_pos.empty() ? json_null()
|
||||
: json_string(m_gtid_binlog_pos.to_string().c_str()));
|
||||
m_gtid_binlog_pos.empty() ? json_null() :
|
||||
json_string(m_gtid_binlog_pos.to_string().c_str()));
|
||||
|
||||
json_object_set_new(result,
|
||||
"master_group",
|
||||
@ -812,8 +812,8 @@ bool MariaDBServer::update_slave_status(string* errmsg_out)
|
||||
if (rval)
|
||||
{
|
||||
/** Store master_id of current node. */
|
||||
m_server_base->server->master_id = !m_slave_status.empty()
|
||||
? m_slave_status[0].master_server_id : SERVER_ID_UNKNOWN;
|
||||
m_server_base->server->master_id = !m_slave_status.empty() ?
|
||||
m_slave_status[0].master_server_id : SERVER_ID_UNKNOWN;
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
@ -1346,8 +1346,8 @@ json_t* SlaveStatus::to_json() const
|
||||
json_object_set_new(result, "slave_sql_running", json_string(slave_sql_running ? "Yes" : "No"));
|
||||
json_object_set_new(result,
|
||||
"seconds_behing_master",
|
||||
seconds_behind_master == MXS_RLAG_UNDEFINED ? json_null()
|
||||
: json_integer(seconds_behind_master));
|
||||
seconds_behind_master == MXS_RLAG_UNDEFINED ? json_null() :
|
||||
json_integer(seconds_behind_master));
|
||||
json_object_set_new(result, "master_server_id", json_integer(master_server_id));
|
||||
json_object_set_new(result, "last_io_or_sql_error", json_string(last_error.c_str()));
|
||||
json_object_set_new(result, "gtid_io_pos", json_string(gtid_io_pos.to_string().c_str()));
|
||||
|
@ -119,10 +119,10 @@ int MariaDBMonitor::Test::run_tests()
|
||||
|
||||
// Test 4: 10 servers, with a big cycle composed of two smaller ones plus non-cycle servers
|
||||
init_servers(10);
|
||||
EdgeArray edges4
|
||||
= { { {1, 5}, {2, 1}, {2, 5}, {3, 1}, {3, 4}, {3, 10}, {4, 1}, {5, 6}, {6, 7}, {6, 4}, {7, 8},
|
||||
{8, 6},
|
||||
{9, 8}}};
|
||||
EdgeArray edges4 =
|
||||
{ { {1, 5}, {2, 1}, {2, 5}, {3, 1}, {3, 4}, {3, 10}, {4, 1}, {5, 6}, {6, 7}, {6, 4}, {7, 8},
|
||||
{8, 6},
|
||||
{9, 8}}};
|
||||
add_replication(edges4);
|
||||
CycleArray expected_cycles4 = { { { {1, 5, 6, 7, 8, 4}}}};
|
||||
results.push_back(check_result_cycles(expected_cycles4));
|
||||
|
@ -34,20 +34,23 @@ int test1()
|
||||
};
|
||||
|
||||
std::vector<TestCase> cases = {
|
||||
{"0-1-1", "0-1-1"},
|
||||
{"4321-1234-4321", "4321-1234-4321"},
|
||||
{"blah", ""},
|
||||
{"1x2x3", ""},
|
||||
{"1-2-3-4", ""},
|
||||
{"45-54-123456789,0-1-2", "0-1-2,45-54-123456789"},
|
||||
{"0-1-1", "0-1-1" },
|
||||
{"4321-1234-4321", "4321-1234-4321" },
|
||||
{"blah", "" },
|
||||
{"1x2x3", "" },
|
||||
{"1-2-3-4", "" },
|
||||
{"45-54-123456789,0-1-2", "0-1-2,45-54-123456789" },
|
||||
{"1-1-1,2-2-2,287-234-134,9-9-9,7-7-7", "1-1-1,2-2-2,7-7-7,9-9-9,287-234-134"},
|
||||
{"1-1-1,3-3-3,a-b-c", ""},
|
||||
{"-2--2--2",""},
|
||||
{"2-2-i",""},
|
||||
{"2-i-2",""},
|
||||
{"i-2-2",""},
|
||||
{"1-1-1,",""},
|
||||
{"3-1-0,3-2-4", "3-1-0,3-2-4"}, // Invalid triplet, but this case is not detected by the parser.
|
||||
{"1-1-1,3-3-3,a-b-c", "" },
|
||||
{"-2--2--2", "" },
|
||||
{"2-2-i", "" },
|
||||
{"2-i-2", "" },
|
||||
{"i-2-2", "" },
|
||||
{"1-1-1,", "" },
|
||||
{"3-1-0,3-2-4", "3-1-0,3-2-4" }, // Invalid triplet,
|
||||
// but this case is
|
||||
// not detected by the
|
||||
// parser.
|
||||
};
|
||||
|
||||
int errors = 0;
|
||||
@ -56,8 +59,8 @@ int test1()
|
||||
string output = GtidList::from_string(test_case.input).to_string();
|
||||
if (output != test_case.result)
|
||||
{
|
||||
cout << "Wrong result: '" << test_case.input << "' produced '" << output << "' while '" <<
|
||||
test_case.result << "' was expected.\n";
|
||||
cout << "Wrong result: '" << test_case.input << "' produced '" << output << "' while '"
|
||||
<< test_case.result << "' was expected.\n";
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
@ -77,22 +80,22 @@ int test2()
|
||||
|
||||
struct TestCase
|
||||
{
|
||||
string input1;
|
||||
string input2;
|
||||
string input1;
|
||||
string input2;
|
||||
sub_mode mode;
|
||||
uint64_t result;
|
||||
};
|
||||
|
||||
std::vector<TestCase> cases = {
|
||||
{"1-2-3", "1-2-3", ignore, 0},
|
||||
{"1-2-3,2-3-4", "1-2-3", lhs_add, 4},
|
||||
{"1-2-3,2-3-4", "1-2-3", ignore, 0},
|
||||
{"3-2-1,4-3-2", "4-3-1,3-1-0", lhs_add, 2},
|
||||
{"1-2-3,2-2-4,3-2-5", "1-2-3", lhs_add, 9},
|
||||
{"1-1-1000000,2-2-2000000", "1-1-1,2-2-2", ignore, 2999997},
|
||||
{"4-4-4,7-4-7,5-4-5,6-4-6,", "1-4-1", lhs_add, 0},
|
||||
{"4-4-4,7-4-7,5-4-5,6-4-6", "1-4-1", lhs_add, 22},
|
||||
{"5-1-4,", "5-1-2", ignore, 0},
|
||||
{"1-2-3", "1-2-3", ignore, 0 },
|
||||
{"1-2-3,2-3-4", "1-2-3", lhs_add, 4 },
|
||||
{"1-2-3,2-3-4", "1-2-3", ignore, 0 },
|
||||
{"3-2-1,4-3-2", "4-3-1,3-1-0", lhs_add, 2 },
|
||||
{"1-2-3,2-2-4,3-2-5", "1-2-3", lhs_add, 9 },
|
||||
{"1-1-1000000,2-2-2000000", "1-1-1,2-2-2", ignore, 2999997},
|
||||
{"4-4-4,7-4-7,5-4-5,6-4-6,", "1-4-1", lhs_add, 0 },
|
||||
{"4-4-4,7-4-7,5-4-5,6-4-6", "1-4-1", lhs_add, 22 },
|
||||
{"5-1-4,", "5-1-2", ignore, 0 },
|
||||
};
|
||||
|
||||
int errors = 0;
|
||||
@ -103,8 +106,8 @@ int test2()
|
||||
auto output = gtid1.events_ahead(gtid2, test_case.mode);
|
||||
if (output != test_case.result)
|
||||
{
|
||||
cout << "Wrong result: '" << test_case.input1 << "' and '" << test_case.input2 <<
|
||||
"' produced '" << output << "' while '" << test_case.result << "' was expected.\n";
|
||||
cout << "Wrong result: '" << test_case.input1 << "' and '" << test_case.input2
|
||||
<< "' produced '" << output << "' while '" << test_case.result << "' was expected.\n";
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user