MXS-2342 Run MariaDBMonitor diagnostics concurrent with the monitor loop
This fixes some situations where MaxAdmin/MaxCtrl would block and wait until a monitor operation or tick is complete. This also fixes a deadlock caused by calling monitor diagnostics inside a monitor script. Concurrency is enabled by adding one mutex per server object to protect array-like fields from concurrent reading/writing.
This commit is contained in:
@ -15,6 +15,7 @@
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <maxscale/monitor.h>
|
||||
#include <maxbase/stopwatch.hh>
|
||||
#include "server_utils.hh"
|
||||
@ -114,6 +115,7 @@ public:
|
||||
bool log_slave_updates = false; /* Does the slave write replicated events to binlog? */
|
||||
};
|
||||
|
||||
|
||||
/* Monitored server base class/struct. MariaDBServer does not own the struct, it is not freed
|
||||
* (or connection closed) when a MariaDBServer is destroyed. */
|
||||
MXS_MONITORED_SERVER* m_server_base = NULL;
|
||||
@ -548,6 +550,12 @@ private:
|
||||
DISABLE
|
||||
};
|
||||
|
||||
/* Protects array-like fields from concurrent access. This is only required for fields which can be
|
||||
* read from another thread while the monitor is running. In practice, these are fields read during
|
||||
* diagnostics-methods. Reading inside monitor thread does not need to be mutexed, as outside threads
|
||||
* only read the values. */
|
||||
mutable std::mutex m_arraylock;
|
||||
|
||||
bool update_slave_status(std::string* errmsg_out = NULL);
|
||||
bool sstatus_array_topology_equal(const SlaveStatusArray& new_slave_status);
|
||||
const SlaveStatus* sstatus_find_previous_row(const SlaveStatus& new_row, size_t guess);
|
||||
|
Reference in New Issue
Block a user