mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Post-review fixes + some bugs fixed + several minor features
This commit is contained in:
@ -19,6 +19,7 @@
|
||||
#include <my_global.h>
|
||||
#include <my_sys.h>
|
||||
#include <my_list.h>
|
||||
#include "thread_registry.h"
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma interface
|
||||
@ -26,9 +27,8 @@
|
||||
|
||||
class Instance;
|
||||
class Instance_map;
|
||||
|
||||
#include "thread_registry.h"
|
||||
#include "instance.h"
|
||||
class Thread_registry;
|
||||
struct GUARD_NODE;
|
||||
|
||||
C_MODE_START
|
||||
|
||||
@ -36,19 +36,11 @@ pthread_handler_decl(guardian, arg);
|
||||
|
||||
C_MODE_END
|
||||
|
||||
typedef struct st_guard_node
|
||||
{
|
||||
Instance *instance;
|
||||
uint restart_counter;
|
||||
time_t crash_moment;
|
||||
} GUARD_NODE;
|
||||
|
||||
|
||||
struct Guardian_thread_args
|
||||
{
|
||||
Thread_registry &thread_registry;
|
||||
Instance_map *instance_map;
|
||||
uint monitoring_interval;
|
||||
int monitoring_interval;
|
||||
|
||||
Guardian_thread_args(Thread_registry &thread_registry_arg,
|
||||
Instance_map *instance_map_arg,
|
||||
@ -72,36 +64,41 @@ public:
|
||||
Instance_map *instance_map_arg,
|
||||
uint monitoring_interval_arg);
|
||||
~Guardian_thread();
|
||||
/* Main funtion of the thread */
|
||||
void run();
|
||||
int start();
|
||||
void shutdown();
|
||||
void request_stop_instances();
|
||||
/* Initialize list of guarded instances */
|
||||
int init();
|
||||
/* Request guardian shutdown. Stop instances if needed */
|
||||
void request_shutdown(bool stop_instances);
|
||||
/* Start instance protection */
|
||||
int guard(Instance *instance);
|
||||
/* Stop instance protection */
|
||||
int stop_guard(Instance *instance);
|
||||
bool is_stopped;
|
||||
/* Returns true if guardian thread is stopped */
|
||||
int is_stopped();
|
||||
|
||||
public:
|
||||
pthread_cond_t COND_guardian;
|
||||
|
||||
private:
|
||||
int stop_instances();
|
||||
int add_instance_to_list(Instance *instance, LIST **list);
|
||||
void move_to_list(LIST **from, LIST **to);
|
||||
/* Prepares Guardian shutdown. Stops instances is needed */
|
||||
int stop_instances(bool stop_instances_arg);
|
||||
/* check instance state and act accordingly */
|
||||
void process_instance(Instance *instance, GUARD_NODE *current_node,
|
||||
LIST **guarded_instances, LIST *elem);
|
||||
int stopped;
|
||||
|
||||
private:
|
||||
/* states of an instance */
|
||||
enum { NOT_STARTED= 1, STARTING, STARTED, JUST_CRASHED, CRASHED,
|
||||
CRASHED_AND_ABANDONED, STOPPING };
|
||||
pthread_mutex_t LOCK_guardian;
|
||||
Thread_info thread_info;
|
||||
LIST *guarded_instances;
|
||||
LIST *starting_instances;
|
||||
MEM_ROOT alloc;
|
||||
enum { MEM_ROOT_BLOCK_SIZE= 512 };
|
||||
/* this variable is set to TRUE when we want to stop Guardian thread */
|
||||
bool shutdown_guardian;
|
||||
/*
|
||||
This var is usually set together with shutdown_guardian. this way we
|
||||
request guardian to shut down all instances before termination
|
||||
*/
|
||||
bool request_stop;
|
||||
bool shutdown_requested;
|
||||
};
|
||||
|
||||
#endif /* INCLUDES_MYSQL_INSTANCE_MANAGER_GUARDIAN_H */
|
||||
|
Reference in New Issue
Block a user