mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Fix for BUG#17486: IM: race condition on exit.
The problem was that IM stoped guarded instances on shutdown, but didn't wait for them to stop. The fix is to wait for guarded instances to stop before exitting from the main thread. The idea is that Instance-monitoring thread should add itself to Thread_registry so that it will be taken into account on shutdown. However, Thread_registry should not signal it on shutdown in order to not interrupt wait()/waitpid(). server-tools/instance-manager/guardian.cc: Be more verbose. server-tools/instance-manager/instance.cc: Register mysqld-monitoring thread in Thread_registry. server-tools/instance-manager/instance.h: Add reference to Thread_registry. server-tools/instance-manager/instance_map.cc: Pass Thread_registry reference to Instance. server-tools/instance-manager/instance_map.h: Add reference to Thread_registry. server-tools/instance-manager/listener.cc: Be more verbose. server-tools/instance-manager/manager.cc: Be more verbose. server-tools/instance-manager/mysql_connection.cc: Eliminate type-conversion warnings. server-tools/instance-manager/thread_registry.cc: Be more verbose. server-tools/instance-manager/thread_registry.h: Eliminate copy&paste, make impl-specific constructor private.
This commit is contained in:
@ -74,7 +74,7 @@ Guardian_thread::Guardian_thread(Thread_registry &thread_registry_arg,
|
||||
uint monitoring_interval_arg) :
|
||||
Guardian_thread_args(thread_registry_arg, instance_map_arg,
|
||||
monitoring_interval_arg),
|
||||
thread_info(pthread_self()), guarded_instances(0)
|
||||
thread_info(pthread_self(), TRUE), guarded_instances(0)
|
||||
{
|
||||
pthread_mutex_init(&LOCK_guardian, 0);
|
||||
pthread_cond_init(&COND_guardian, 0);
|
||||
@ -250,6 +250,8 @@ void Guardian_thread::run()
|
||||
LIST *node;
|
||||
struct timespec timeout;
|
||||
|
||||
log_info("Guardian: started.");
|
||||
|
||||
thread_registry.register_thread(&thread_info);
|
||||
|
||||
my_thread_init();
|
||||
@ -277,12 +279,16 @@ void Guardian_thread::run()
|
||||
&LOCK_guardian, &timeout);
|
||||
}
|
||||
|
||||
log_info("Guardian: stopped.");
|
||||
|
||||
stopped= TRUE;
|
||||
pthread_mutex_unlock(&LOCK_guardian);
|
||||
/* now, when the Guardian is stopped we can stop the IM */
|
||||
thread_registry.unregister_thread(&thread_info);
|
||||
thread_registry.request_shutdown();
|
||||
my_thread_end();
|
||||
|
||||
log_info("Guardian: finished.");
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user