Construct diagnostics results in the monitor thread

MariaDBMonitor diagnostics printing is unsafe as some of the read
fields are arrays. To be on the safe side, the fields are now read
in the monitor worker thread.

Since diagnostics must work even for stopped monitors, a worker task
is used. In practice, it usually runs when the monitor is sleeping.
This commit is contained in:
Esa Korhonen
2018-06-28 16:08:52 +03:00
parent 590df89dbc
commit 862ae099b0
5 changed files with 138 additions and 16 deletions

View File

@ -104,6 +104,7 @@ protected:
void process_state_changes();
private:
typedef std::function<void ()> GenericFunction;
struct CycleInfo
{
@ -188,7 +189,10 @@ private:
bool set_replication_credentials(const MXS_CONFIG_PARAMETER* params);
MariaDBServer* get_server_info(MXS_MONITORED_SERVER* db);
MariaDBServer* get_server(int64_t id);
bool execute_manual_command(std::function<void (void)> command, json_t** error_out);
bool execute_manual_command(GenericFunction command, json_t** error_out);
bool execute_worker_task(GenericFunction func);
std::string diagnostics_to_string() const;
json_t* diagnostics_to_json() const;
// Cluster discovery and status assignment methods
void update_server(MariaDBServer& server);