From 551bb819290a9e9de67c8563b6bafccf1885fd76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Fri, 27 Oct 2017 14:40:27 +0300 Subject: [PATCH] Loosen the atomicity requirement for the passive parameter As the passive parameter is only used by the failover and the failover can only be initiated by the monitor, there is no true need to synchronize the reads and write of this parameter. As all runtime changes are protected by the runtime lock, only partial reads are of concern. For the supported platforms, this is not a practical problem and it only confuses the reader when other variables are modified without atomic operations. --- server/core/config_runtime.cc | 4 ++-- server/core/monitor.cc | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/server/core/config_runtime.cc b/server/core/config_runtime.cc index 623bcceed..332ecdd56 100644 --- a/server/core/config_runtime.cc +++ b/server/core/config_runtime.cc @@ -763,10 +763,10 @@ bool runtime_alter_maxscale(const char* name, const char* value) if (cnf.passive && !boolval) { // This MaxScale is being promoted to the active instance - atomic_store_int64(&cnf.promoted_at, hkheartbeat); + cnf.promoted_at = hkheartbeat; } - atomic_store_int32(&cnf.passive, boolval); + cnf.passive = boolval; rval = true; } else diff --git a/server/core/monitor.cc b/server/core/monitor.cc index 5d902b716..ddc4b9818 100644 --- a/server/core/monitor.cc +++ b/server/core/monitor.cc @@ -1758,7 +1758,7 @@ void mon_process_state_changes(MXS_MONITOR *monitor, const char *script, uint64_ mxs_monitor_event_t event = mon_get_event_type(ptr); ptr->server->last_event = event; ptr->server->triggered_at = hkheartbeat; - ptr->server->active_event = !atomic_load_int32(&config_get_global_options()->passive); + ptr->server->active_event = !config_get_global_options()->passive; ptr->new_event = true; mon_log_state_change(ptr);