mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Fix for BUG#28030: test im_instance_conf fails with an assert.
The problem was a race condition on shutdown -- when IM got shutdown request while a guarded mysqld is starting. In this case the Guardian thread tried to stop the mysqld, but might fail if the mysqld hadn't created pid-file so far. When this happened, the mysqld-monitor thread didn't stop, so the assert in Thread_registry happened. The fix is to make several attempts to stop mysqld if it is active. server-tools/instance-manager/guardian.cc: Try to stop mysqld several times if it is still active. server-tools/instance-manager/instance.cc: Make Instance::kill_mysqld() to return operation status. server-tools/instance-manager/instance.h: Make Instance::kill_mysqld() to return operation status. server-tools/instance-manager/thread_registry.cc: Log unregistered thread ids.
This commit is contained in:
@ -403,6 +403,8 @@ void Guardian::init()
|
||||
|
||||
void Guardian::stop_instances()
|
||||
{
|
||||
static const int NUM_STOP_ATTEMPTS = 100;
|
||||
|
||||
Instance_map::Iterator instances_it(instance_map);
|
||||
Instance *instance;
|
||||
|
||||
@ -438,7 +440,34 @@ void Guardian::stop_instances()
|
||||
|
||||
/* Request mysqld to stop. */
|
||||
|
||||
instance->kill_mysqld(SIGTERM);
|
||||
bool instance_stopped= FALSE;
|
||||
|
||||
for (int cur_attempt= 0; cur_attempt < NUM_STOP_ATTEMPTS; ++cur_attempt)
|
||||
{
|
||||
if (!instance->kill_mysqld(SIGTERM))
|
||||
{
|
||||
instance_stopped= TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!instance->is_active())
|
||||
{
|
||||
instance_stopped= TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Sleep for 0.3 sec and check again. */
|
||||
|
||||
my_sleep(300000);
|
||||
}
|
||||
|
||||
/*
|
||||
Abort if we failed to stop mysqld instance. That should not happen,
|
||||
but if it happened, we don't know what to do and prefer to have clear
|
||||
failure with coredump.
|
||||
*/
|
||||
|
||||
DBUG_ASSERT(instance_stopped);
|
||||
|
||||
instance->unlock();
|
||||
}
|
||||
|
Reference in New Issue
Block a user