From f91b91cf659118eaf74b077f900a4bfd3405ed7d Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 25 Sep 2006 09:28:52 +0200 Subject: Bug #22379 im_daemon_life_cycle.test fails on merge of 5.1 -> 5.1-engines Remove race situations that occur when removing pidfiles. Primarily each process should remove its own pidfile, secondly it should be removed by the process that created it and _only_ if it's certain the process is dead. Third, mysql-test-run.pl will remove the pidfile when process has been killed. - Set state of an instance to STARTING _before_ calling instance->start() - Check that pidfile of instance has been created before changing STARTING => STARTED - Only remove the pidfile if IM kills an instance with SIGKILL, otherwise the instance will remove it itself server-tools/instance-manager/guardian.cc: If state of an instance is STARTING, chech that the instance pidfile has been created before changing state to STARTED Set state to STARTING before calling instance->start(), it can take some time before it is fully started and during that time it should be in state STARTING server-tools/instance-manager/instance.cc: Only remove the pid file of instance manager when a SIGKILL has been performed sucessfully server-tools/instance-manager/instance_options.cc: Check that fscanf returns 1 which is the number of args that should be scanned from the pid file --- server-tools/instance-manager/instance.cc | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'server-tools/instance-manager/instance.cc') diff --git a/server-tools/instance-manager/instance.cc b/server-tools/instance-manager/instance.cc index 39381b457ab..5c47dc87734 100644 --- a/server-tools/instance-manager/instance.cc +++ b/server-tools/instance-manager/instance.cc @@ -571,18 +571,19 @@ void Instance::kill_instance(int signum) /* if there are no pid, everything seems to be fine */ if ((pid= options.get_pid()) != 0) /* get pid from pidfile */ { - /* - If we cannot kill mysqld, then it has propably crashed. - Let us try to remove staled pidfile and return successfully - as mysqld is probably stopped. - */ - if (!kill(pid, signum)) - options.unlink_pidfile(); - else if (signum == SIGKILL) /* really killed instance with SIGKILL */ - log_error("The instance %s is being stopped forsibly. Normally \ - it should not happed. Probably the instance has been \ - hanging. You should also check your IM setup", - options.instance_name); + if (kill(pid, signum) == 0) + { + /* Kill suceeded */ + if (signum == SIGKILL) /* really killed instance with SIGKILL */ + { + log_error("The instance %s is being stopped forcibly. Normally" \ + "it should not happen. Probably the instance has been" \ + "hanging. You should also check your IM setup", + options.instance_name); + /* After sucessful hard kill the pidfile need to be removed */ + options.unlink_pidfile(); + } + } } return; } -- cgit v1.2.1