Bug #24554 IM: STOP INSTANCE does not work properly if an instance has been started outside
Submitted: 23 Nov 2006 19:35 Modified: 5 Oct 2007 15:33
Reporter: Alexander Nozdrin Email Updates:
Status: Unsupported Impact on me:
None 
Category:Instance Manager Severity:S3 (Non-critical)
Version:5.0 BK OS:Any
Assigned to: CPU Architecture:Any

[23 Nov 2006 19:35] Alexander Nozdrin
Description:
STOP INSTANCE is supposed to be synchronous, i.e. it should wait for
an instance to stop and return after the instance stopped. It can also
return if the instance didn't stop within shutdown_interval (which can
be specified in the configuration).

The problem is that if an instance has been started outside the current
Instance Manager, STOP INSTANCE will always time out.

A nonguarded instance can easily be started outside Instance Manager.

A guarded instance can become "started outside IM", if IM restarted
(by IM-angel, for one) after the instance has been started.

Basically, the problem is that IM has a special thread, that starts
mysqld-instance and blocks on waitpid() system call, i.e. waits for
the process to die. When mysqld dies, the thread set some flag, which
is used by STOP INSTANCE command to understand that the mysqld is gone.

In other words, STOP INSTANCE waits for the flag within shutdown_interval.
If the flag has been set, STOP INSTANCE just returns. If timeout occurs,
IM kills the instance and also returns. (See also BUG#24553).

When Instance Manager is restarted, there is no monitoring-thread
for running mysqlds. So, STOP INSTANCE for such instances will always
timeout.

How to repeat:
1. For guarded instance:
1.1. Configure at least one guarded instance;
1.2. Start Instance Manager in daemon mode;
1.3. Check that guarded instance is up and running;
1.4. Kill Instance Manager by SIGKILL;
1.5. Check that IM-angel has restarted IM-main;
1.6. Check that guarded instance is still up and running;
1.7. Try to stop this guarded instance -- STOP INSTANCE will take
shutdown_interval seconds.

2. For non-guarded instance:
2.1. Configure at least one non-guarded instance;
2.2. Start Instance Manager as a standalone process (the mode
does not matter here, standalone mode is just easier);
2.3. Start non-guarded instance;
2.4. Check that the instance is up and running;
2.5. Restart Instance Manager;
2.6. Check that the instance is still up and running;
2.7. Try to stop this non-guared instance -- STOP INSTANCE will take
shutdown_interval seconds.
[5 Oct 2007 15:33] Konstantin Osipov
The plan is to discontinue the Instance Manager.
[5 Oct 2007 15:33] Konstantin Osipov
Setting to Unsupported unless the decision to discontinue is reverted.