Sort server relationships

As server relationships are unordered, sorting them guarantees a certain
order. This fixes the MaxCtrl cluster diff test failure.

Also formatted monitor.cc sources: the indentation seems to be off.
This commit is contained in:
Markus Mäkelä
2019-05-24 11:02:43 +03:00
parent bed28db3fd
commit 47ebcdcc02
2 changed files with 51 additions and 45 deletions

View File

@ -89,7 +89,6 @@ private:
ThisUnit this_unit;
const char RECONFIG_FAILED[] = "Monitor reconfiguration failed when %s. Check log for more details.";
}
Monitor* MonitorManager::create_monitor(const string& name, const string& module,
@ -140,12 +139,14 @@ void MonitorManager::debug_wait_one_tick()
if (mon->is_running())
{
auto start = steady_clock::now();
// A monitor may have been added in between the two foreach-calls (not if config changes are
// A monitor may have been added in between the two foreach-calls (not
// if config changes are
// serialized). Check if entry exists.
if (ticks.count(mon) > 0)
{
auto tick = ticks[mon];
while (mon->ticks() == tick && (steady_clock::now() - start < seconds(60)))
while (mon->ticks() == tick
&& (steady_clock::now() - start < seconds(60)))
{
std::this_thread::sleep_for(milliseconds(100));
}
@ -479,7 +480,8 @@ json_t* MonitorManager::monitor_relations_to_server(const SERVER* server, const
mxb_assert(Monitor::is_admin_thread());
std::vector<std::string> names;
this_unit.foreach_monitor([&names, server](Monitor* mon) {
// The serverlist of an individual monitor should not change while a monitor is running.
// The serverlist of an individual monitor should not change while a
// monitor is running.
for (MonitorServer* db : mon->servers())
{
if (db->server == server)
@ -491,6 +493,8 @@ json_t* MonitorManager::monitor_relations_to_server(const SERVER* server, const
return true;
});
std::sort(names.begin(), names.end());
json_t* rel = NULL;
if (!names.empty())
{

View File

@ -1801,6 +1801,8 @@ json_t* service_relations_to_server(const SERVER* server, const char* host)
}
}
std::sort(names.begin(), names.end());
json_t* rel = NULL;
if (!names.empty())