2004-10-23 11:32:52 +04:00
|
|
|
/* Copyright (C) 2004 MySQL AB
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __GNUC__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "guardian.h"
|
2005-03-22 02:04:14 +03:00
|
|
|
|
2004-10-23 11:32:52 +04:00
|
|
|
#include "instance_map.h"
|
2005-02-11 14:21:59 +03:00
|
|
|
#include "instance.h"
|
2004-10-26 23:22:12 +04:00
|
|
|
#include "mysql_manager_error.h"
|
|
|
|
#include "log.h"
|
2005-08-05 20:44:52 +02:00
|
|
|
#include "portability.h"
|
2005-03-22 02:04:14 +03:00
|
|
|
|
2004-10-23 11:32:52 +04:00
|
|
|
#include <string.h>
|
2005-02-11 14:21:59 +03:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <signal.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-10-23 11:32:52 +04:00
|
|
|
C_MODE_START
|
|
|
|
|
|
|
|
pthread_handler_decl(guardian, arg)
|
|
|
|
{
|
|
|
|
Guardian_thread *guardian_thread= (Guardian_thread *) arg;
|
|
|
|
guardian_thread->run();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
C_MODE_END
|
|
|
|
|
|
|
|
|
|
|
|
Guardian_thread::Guardian_thread(Thread_registry &thread_registry_arg,
|
|
|
|
Instance_map *instance_map_arg,
|
|
|
|
uint monitoring_interval_arg) :
|
|
|
|
Guardian_thread_args(thread_registry_arg, instance_map_arg,
|
|
|
|
monitoring_interval_arg),
|
2005-02-11 14:21:59 +03:00
|
|
|
thread_info(pthread_self()), guarded_instances(0)
|
2004-10-23 11:32:52 +04:00
|
|
|
{
|
|
|
|
pthread_mutex_init(&LOCK_guardian, 0);
|
2005-01-25 13:54:56 +03:00
|
|
|
pthread_cond_init(&COND_guardian, 0);
|
2005-02-11 14:21:59 +03:00
|
|
|
shutdown_requested= FALSE;
|
|
|
|
stopped= FALSE;
|
2004-10-23 11:32:52 +04:00
|
|
|
init_alloc_root(&alloc, MEM_ROOT_BLOCK_SIZE, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Guardian_thread::~Guardian_thread()
|
|
|
|
{
|
|
|
|
/* delay guardian destruction to the moment when no one needs it */
|
|
|
|
pthread_mutex_lock(&LOCK_guardian);
|
|
|
|
free_root(&alloc, MYF(0));
|
|
|
|
pthread_mutex_unlock(&LOCK_guardian);
|
|
|
|
pthread_mutex_destroy(&LOCK_guardian);
|
2005-01-25 13:54:56 +03:00
|
|
|
pthread_cond_destroy(&COND_guardian);
|
2004-10-23 11:32:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-02-11 14:21:59 +03:00
|
|
|
void Guardian_thread::request_shutdown(bool stop_instances_arg)
|
more fixes for IM to substitude mysqld_safe in startup scripts
BitKeeper/deleted/.del-thread_repository.cc~bba09f64f8cb4037:
Delete: server-tools/instance-manager/thread_repository.cc
BitKeeper/deleted/.del-thread_repository.h~e6a3b9cab7a6612a:
Delete: server-tools/instance-manager/thread_repository.h
server-tools/instance-manager/commands.cc:
All instances are guarded by default now, so we need to perform check on whether the instance is nonguarded,
rather then guarded when adding it to the list of guarded instnces.
server-tools/instance-manager/guardian.cc:
Guardian rewritten to start instances by default, and shut them down, when exiting. Behaviour of the guardian
in case of the instance crash has changed. Now it tries to restart an instance constantly in the first 2
seconds after the crash was noticed, and then it tries restart an instance once in the MONITORING_INTERVAL.
If it failed to restart instance for "restart_retry" (compiled-in value) times, guardian stops trying to
restart it.
server-tools/instance-manager/guardian.h:
Several new functions and variables declared.
server-tools/instance-manager/instance.cc:
now start doesn't call stop(), but rather tries to remove the pidfile itself
server-tools/instance-manager/instance.h:
cleanup
server-tools/instance-manager/instance_map.cc:
no more "admin" options
server-tools/instance-manager/instance_map.h:
User and password purged from instance_map options, as IM shouldn't know them
server-tools/instance-manager/instance_options.cc:
new option added -- shutdown_delay, guarded option now called nonguaded and has the opposite meaning
server-tools/instance-manager/instance_options.h:
appropriate changes, reflecting options addition/removal
server-tools/instance-manager/manager.cc:
shutdown process is complicated a bit -- at first signal thread should stop guardian, and only then the IM
itself
server-tools/instance-manager/messages.cc:
update error message
server-tools/instance-manager/options.cc:
admin user/password purged from mysqlmanager options
2005-01-31 23:54:08 +03:00
|
|
|
{
|
|
|
|
pthread_mutex_lock(&LOCK_guardian);
|
2005-02-11 14:21:59 +03:00
|
|
|
/* stop instances or just clean up Guardian repository */
|
|
|
|
stop_instances(stop_instances_arg);
|
|
|
|
shutdown_requested= TRUE;
|
more fixes for IM to substitude mysqld_safe in startup scripts
BitKeeper/deleted/.del-thread_repository.cc~bba09f64f8cb4037:
Delete: server-tools/instance-manager/thread_repository.cc
BitKeeper/deleted/.del-thread_repository.h~e6a3b9cab7a6612a:
Delete: server-tools/instance-manager/thread_repository.h
server-tools/instance-manager/commands.cc:
All instances are guarded by default now, so we need to perform check on whether the instance is nonguarded,
rather then guarded when adding it to the list of guarded instnces.
server-tools/instance-manager/guardian.cc:
Guardian rewritten to start instances by default, and shut them down, when exiting. Behaviour of the guardian
in case of the instance crash has changed. Now it tries to restart an instance constantly in the first 2
seconds after the crash was noticed, and then it tries restart an instance once in the MONITORING_INTERVAL.
If it failed to restart instance for "restart_retry" (compiled-in value) times, guardian stops trying to
restart it.
server-tools/instance-manager/guardian.h:
Several new functions and variables declared.
server-tools/instance-manager/instance.cc:
now start doesn't call stop(), but rather tries to remove the pidfile itself
server-tools/instance-manager/instance.h:
cleanup
server-tools/instance-manager/instance_map.cc:
no more "admin" options
server-tools/instance-manager/instance_map.h:
User and password purged from instance_map options, as IM shouldn't know them
server-tools/instance-manager/instance_options.cc:
new option added -- shutdown_delay, guarded option now called nonguaded and has the opposite meaning
server-tools/instance-manager/instance_options.h:
appropriate changes, reflecting options addition/removal
server-tools/instance-manager/manager.cc:
shutdown process is complicated a bit -- at first signal thread should stop guardian, and only then the IM
itself
server-tools/instance-manager/messages.cc:
update error message
server-tools/instance-manager/options.cc:
admin user/password purged from mysqlmanager options
2005-01-31 23:54:08 +03:00
|
|
|
pthread_mutex_unlock(&LOCK_guardian);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-02-11 14:21:59 +03:00
|
|
|
void Guardian_thread::process_instance(Instance *instance,
|
|
|
|
GUARD_NODE *current_node,
|
|
|
|
LIST **guarded_instances,
|
2005-02-27 18:41:34 +03:00
|
|
|
LIST *node)
|
more fixes for IM to substitude mysqld_safe in startup scripts
BitKeeper/deleted/.del-thread_repository.cc~bba09f64f8cb4037:
Delete: server-tools/instance-manager/thread_repository.cc
BitKeeper/deleted/.del-thread_repository.h~e6a3b9cab7a6612a:
Delete: server-tools/instance-manager/thread_repository.h
server-tools/instance-manager/commands.cc:
All instances are guarded by default now, so we need to perform check on whether the instance is nonguarded,
rather then guarded when adding it to the list of guarded instnces.
server-tools/instance-manager/guardian.cc:
Guardian rewritten to start instances by default, and shut them down, when exiting. Behaviour of the guardian
in case of the instance crash has changed. Now it tries to restart an instance constantly in the first 2
seconds after the crash was noticed, and then it tries restart an instance once in the MONITORING_INTERVAL.
If it failed to restart instance for "restart_retry" (compiled-in value) times, guardian stops trying to
restart it.
server-tools/instance-manager/guardian.h:
Several new functions and variables declared.
server-tools/instance-manager/instance.cc:
now start doesn't call stop(), but rather tries to remove the pidfile itself
server-tools/instance-manager/instance.h:
cleanup
server-tools/instance-manager/instance_map.cc:
no more "admin" options
server-tools/instance-manager/instance_map.h:
User and password purged from instance_map options, as IM shouldn't know them
server-tools/instance-manager/instance_options.cc:
new option added -- shutdown_delay, guarded option now called nonguaded and has the opposite meaning
server-tools/instance-manager/instance_options.h:
appropriate changes, reflecting options addition/removal
server-tools/instance-manager/manager.cc:
shutdown process is complicated a bit -- at first signal thread should stop guardian, and only then the IM
itself
server-tools/instance-manager/messages.cc:
update error message
server-tools/instance-manager/options.cc:
admin user/password purged from mysqlmanager options
2005-01-31 23:54:08 +03:00
|
|
|
{
|
2005-02-27 18:41:34 +03:00
|
|
|
uint waitchild= (uint) Instance::DEFAULT_SHUTDOWN_DELAY;
|
2005-02-11 14:21:59 +03:00
|
|
|
/* The amount of times, Guardian attempts to restart an instance */
|
|
|
|
int restart_retry= 100;
|
|
|
|
time_t current_time= time(NULL);
|
|
|
|
|
|
|
|
if (current_node->state == STOPPING)
|
|
|
|
{
|
|
|
|
/* this brach is executed during shutdown */
|
2005-02-27 18:41:34 +03:00
|
|
|
if (instance->options.shutdown_delay_val)
|
|
|
|
waitchild= instance->options.shutdown_delay_val;
|
2005-02-11 14:21:59 +03:00
|
|
|
|
2005-02-27 18:41:34 +03:00
|
|
|
/* this returns true if and only if an instance was stopped for sure */
|
2005-02-11 14:21:59 +03:00
|
|
|
if (instance->is_crashed())
|
2005-02-27 18:41:34 +03:00
|
|
|
*guarded_instances= list_delete(*guarded_instances, node);
|
|
|
|
else if ( (uint) (current_time - current_node->last_checked) > waitchild)
|
|
|
|
{
|
|
|
|
instance->kill_instance(SIGKILL);
|
|
|
|
/*
|
|
|
|
Later we do node= node->next. This is ok, as we are only removing
|
|
|
|
the node from the list. The pointer to the next one is still valid.
|
|
|
|
*/
|
|
|
|
*guarded_instances= list_delete(*guarded_instances, node);
|
|
|
|
}
|
2005-02-11 14:21:59 +03:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (instance->is_running())
|
|
|
|
{
|
|
|
|
/* clear status fields */
|
|
|
|
current_node->restart_counter= 0;
|
|
|
|
current_node->crash_moment= 0;
|
|
|
|
current_node->state= STARTED;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch (current_node->state)
|
|
|
|
{
|
|
|
|
case NOT_STARTED:
|
|
|
|
instance->start();
|
|
|
|
current_node->last_checked= current_time;
|
|
|
|
log_info("guardian: starting instance %s",
|
|
|
|
instance->options.instance_name);
|
|
|
|
current_node->state= STARTING;
|
|
|
|
break;
|
|
|
|
case STARTED: /* fallthrough */
|
|
|
|
case STARTING: /* let the instance start or crash */
|
|
|
|
if (instance->is_crashed())
|
|
|
|
{
|
|
|
|
current_node->crash_moment= current_time;
|
|
|
|
current_node->last_checked= current_time;
|
|
|
|
current_node->state= JUST_CRASHED;
|
|
|
|
/* fallthrough -- restart an instance immediately */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
case JUST_CRASHED:
|
|
|
|
if (current_time - current_node->crash_moment <= 2)
|
|
|
|
{
|
|
|
|
instance->start();
|
|
|
|
log_info("guardian: starting instance %s",
|
|
|
|
instance->options.instance_name);
|
|
|
|
}
|
|
|
|
else current_node->state= CRASHED;
|
|
|
|
break;
|
|
|
|
case CRASHED: /* just regular restarts */
|
|
|
|
if (current_time - current_node->last_checked >
|
|
|
|
monitoring_interval)
|
|
|
|
{
|
|
|
|
if ((current_node->restart_counter < restart_retry))
|
|
|
|
{
|
|
|
|
instance->start();
|
|
|
|
current_node->last_checked= current_time;
|
2005-02-27 18:41:34 +03:00
|
|
|
current_node->restart_counter++;
|
|
|
|
log_info("guardian: restarting instance %s",
|
2005-02-11 14:21:59 +03:00
|
|
|
instance->options.instance_name);
|
|
|
|
}
|
2005-02-27 18:41:34 +03:00
|
|
|
else
|
|
|
|
current_node->state= CRASHED_AND_ABANDONED;
|
2005-02-11 14:21:59 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CRASHED_AND_ABANDONED:
|
|
|
|
break; /* do nothing */
|
|
|
|
default:
|
|
|
|
DBUG_ASSERT(0);
|
|
|
|
}
|
|
|
|
}
|
more fixes for IM to substitude mysqld_safe in startup scripts
BitKeeper/deleted/.del-thread_repository.cc~bba09f64f8cb4037:
Delete: server-tools/instance-manager/thread_repository.cc
BitKeeper/deleted/.del-thread_repository.h~e6a3b9cab7a6612a:
Delete: server-tools/instance-manager/thread_repository.h
server-tools/instance-manager/commands.cc:
All instances are guarded by default now, so we need to perform check on whether the instance is nonguarded,
rather then guarded when adding it to the list of guarded instnces.
server-tools/instance-manager/guardian.cc:
Guardian rewritten to start instances by default, and shut them down, when exiting. Behaviour of the guardian
in case of the instance crash has changed. Now it tries to restart an instance constantly in the first 2
seconds after the crash was noticed, and then it tries restart an instance once in the MONITORING_INTERVAL.
If it failed to restart instance for "restart_retry" (compiled-in value) times, guardian stops trying to
restart it.
server-tools/instance-manager/guardian.h:
Several new functions and variables declared.
server-tools/instance-manager/instance.cc:
now start doesn't call stop(), but rather tries to remove the pidfile itself
server-tools/instance-manager/instance.h:
cleanup
server-tools/instance-manager/instance_map.cc:
no more "admin" options
server-tools/instance-manager/instance_map.h:
User and password purged from instance_map options, as IM shouldn't know them
server-tools/instance-manager/instance_options.cc:
new option added -- shutdown_delay, guarded option now called nonguaded and has the opposite meaning
server-tools/instance-manager/instance_options.h:
appropriate changes, reflecting options addition/removal
server-tools/instance-manager/manager.cc:
shutdown process is complicated a bit -- at first signal thread should stop guardian, and only then the IM
itself
server-tools/instance-manager/messages.cc:
update error message
server-tools/instance-manager/options.cc:
admin user/password purged from mysqlmanager options
2005-01-31 23:54:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-23 11:32:52 +04:00
|
|
|
/*
|
|
|
|
Run guardian thread
|
|
|
|
|
|
|
|
SYNOPSYS
|
|
|
|
run()
|
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
|
|
|
|
Check for all guarded instances and restart them if needed. If everything
|
|
|
|
is fine go and sleep for some time.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void Guardian_thread::run()
|
|
|
|
{
|
|
|
|
Instance *instance;
|
2005-02-27 18:41:34 +03:00
|
|
|
LIST *node;
|
2005-01-25 13:54:56 +03:00
|
|
|
struct timespec timeout;
|
2004-10-23 11:32:52 +04:00
|
|
|
|
2005-02-03 20:48:58 +03:00
|
|
|
thread_registry.register_thread(&thread_info);
|
|
|
|
|
2004-10-23 11:32:52 +04:00
|
|
|
my_thread_init();
|
2005-01-25 13:54:56 +03:00
|
|
|
pthread_mutex_lock(&LOCK_guardian);
|
|
|
|
|
2005-02-11 14:21:59 +03:00
|
|
|
/* loop, until all instances were shut down at the end */
|
|
|
|
while (!(shutdown_requested && (guarded_instances == NULL)))
|
2004-10-23 11:32:52 +04:00
|
|
|
{
|
2005-02-27 18:41:34 +03:00
|
|
|
node= guarded_instances;
|
2005-02-03 20:48:58 +03:00
|
|
|
|
2005-02-27 18:41:34 +03:00
|
|
|
while (node != NULL)
|
2004-10-23 11:32:52 +04:00
|
|
|
{
|
2005-02-11 14:21:59 +03:00
|
|
|
struct timespec timeout;
|
more fixes for IM to substitude mysqld_safe in startup scripts
BitKeeper/deleted/.del-thread_repository.cc~bba09f64f8cb4037:
Delete: server-tools/instance-manager/thread_repository.cc
BitKeeper/deleted/.del-thread_repository.h~e6a3b9cab7a6612a:
Delete: server-tools/instance-manager/thread_repository.h
server-tools/instance-manager/commands.cc:
All instances are guarded by default now, so we need to perform check on whether the instance is nonguarded,
rather then guarded when adding it to the list of guarded instnces.
server-tools/instance-manager/guardian.cc:
Guardian rewritten to start instances by default, and shut them down, when exiting. Behaviour of the guardian
in case of the instance crash has changed. Now it tries to restart an instance constantly in the first 2
seconds after the crash was noticed, and then it tries restart an instance once in the MONITORING_INTERVAL.
If it failed to restart instance for "restart_retry" (compiled-in value) times, guardian stops trying to
restart it.
server-tools/instance-manager/guardian.h:
Several new functions and variables declared.
server-tools/instance-manager/instance.cc:
now start doesn't call stop(), but rather tries to remove the pidfile itself
server-tools/instance-manager/instance.h:
cleanup
server-tools/instance-manager/instance_map.cc:
no more "admin" options
server-tools/instance-manager/instance_map.h:
User and password purged from instance_map options, as IM shouldn't know them
server-tools/instance-manager/instance_options.cc:
new option added -- shutdown_delay, guarded option now called nonguaded and has the opposite meaning
server-tools/instance-manager/instance_options.h:
appropriate changes, reflecting options addition/removal
server-tools/instance-manager/manager.cc:
shutdown process is complicated a bit -- at first signal thread should stop guardian, and only then the IM
itself
server-tools/instance-manager/messages.cc:
update error message
server-tools/instance-manager/options.cc:
admin user/password purged from mysqlmanager options
2005-01-31 23:54:08 +03:00
|
|
|
|
2005-02-27 18:41:34 +03:00
|
|
|
GUARD_NODE *current_node= (GUARD_NODE *) node->data;
|
|
|
|
instance= ((GUARD_NODE *) node->data)->instance;
|
|
|
|
process_instance(instance, current_node, &guarded_instances, node);
|
more fixes for IM to substitude mysqld_safe in startup scripts
BitKeeper/deleted/.del-thread_repository.cc~bba09f64f8cb4037:
Delete: server-tools/instance-manager/thread_repository.cc
BitKeeper/deleted/.del-thread_repository.h~e6a3b9cab7a6612a:
Delete: server-tools/instance-manager/thread_repository.h
server-tools/instance-manager/commands.cc:
All instances are guarded by default now, so we need to perform check on whether the instance is nonguarded,
rather then guarded when adding it to the list of guarded instnces.
server-tools/instance-manager/guardian.cc:
Guardian rewritten to start instances by default, and shut them down, when exiting. Behaviour of the guardian
in case of the instance crash has changed. Now it tries to restart an instance constantly in the first 2
seconds after the crash was noticed, and then it tries restart an instance once in the MONITORING_INTERVAL.
If it failed to restart instance for "restart_retry" (compiled-in value) times, guardian stops trying to
restart it.
server-tools/instance-manager/guardian.h:
Several new functions and variables declared.
server-tools/instance-manager/instance.cc:
now start doesn't call stop(), but rather tries to remove the pidfile itself
server-tools/instance-manager/instance.h:
cleanup
server-tools/instance-manager/instance_map.cc:
no more "admin" options
server-tools/instance-manager/instance_map.h:
User and password purged from instance_map options, as IM shouldn't know them
server-tools/instance-manager/instance_options.cc:
new option added -- shutdown_delay, guarded option now called nonguaded and has the opposite meaning
server-tools/instance-manager/instance_options.h:
appropriate changes, reflecting options addition/removal
server-tools/instance-manager/manager.cc:
shutdown process is complicated a bit -- at first signal thread should stop guardian, and only then the IM
itself
server-tools/instance-manager/messages.cc:
update error message
server-tools/instance-manager/options.cc:
admin user/password purged from mysqlmanager options
2005-01-31 23:54:08 +03:00
|
|
|
|
2005-02-27 18:41:34 +03:00
|
|
|
node= node->next;
|
2004-10-23 11:32:52 +04:00
|
|
|
}
|
2005-01-25 13:54:56 +03:00
|
|
|
timeout.tv_sec= time(NULL) + monitoring_interval;
|
|
|
|
timeout.tv_nsec= 0;
|
|
|
|
|
2005-02-11 14:21:59 +03:00
|
|
|
/* check the loop predicate before sleeping */
|
2005-02-27 18:41:34 +03:00
|
|
|
if (!(shutdown_requested && (!(guarded_instances))))
|
2005-02-11 14:21:59 +03:00
|
|
|
pthread_cond_timedwait(&COND_guardian, &LOCK_guardian, &timeout);
|
2004-10-23 11:32:52 +04:00
|
|
|
}
|
|
|
|
|
2005-02-11 14:21:59 +03:00
|
|
|
stopped= TRUE;
|
2005-01-25 13:54:56 +03:00
|
|
|
pthread_mutex_unlock(&LOCK_guardian);
|
more fixes for IM to substitude mysqld_safe in startup scripts
BitKeeper/deleted/.del-thread_repository.cc~bba09f64f8cb4037:
Delete: server-tools/instance-manager/thread_repository.cc
BitKeeper/deleted/.del-thread_repository.h~e6a3b9cab7a6612a:
Delete: server-tools/instance-manager/thread_repository.h
server-tools/instance-manager/commands.cc:
All instances are guarded by default now, so we need to perform check on whether the instance is nonguarded,
rather then guarded when adding it to the list of guarded instnces.
server-tools/instance-manager/guardian.cc:
Guardian rewritten to start instances by default, and shut them down, when exiting. Behaviour of the guardian
in case of the instance crash has changed. Now it tries to restart an instance constantly in the first 2
seconds after the crash was noticed, and then it tries restart an instance once in the MONITORING_INTERVAL.
If it failed to restart instance for "restart_retry" (compiled-in value) times, guardian stops trying to
restart it.
server-tools/instance-manager/guardian.h:
Several new functions and variables declared.
server-tools/instance-manager/instance.cc:
now start doesn't call stop(), but rather tries to remove the pidfile itself
server-tools/instance-manager/instance.h:
cleanup
server-tools/instance-manager/instance_map.cc:
no more "admin" options
server-tools/instance-manager/instance_map.h:
User and password purged from instance_map options, as IM shouldn't know them
server-tools/instance-manager/instance_options.cc:
new option added -- shutdown_delay, guarded option now called nonguaded and has the opposite meaning
server-tools/instance-manager/instance_options.h:
appropriate changes, reflecting options addition/removal
server-tools/instance-manager/manager.cc:
shutdown process is complicated a bit -- at first signal thread should stop guardian, and only then the IM
itself
server-tools/instance-manager/messages.cc:
update error message
server-tools/instance-manager/options.cc:
admin user/password purged from mysqlmanager options
2005-01-31 23:54:08 +03:00
|
|
|
/* now, when the Guardian is stopped we can stop the IM */
|
2005-02-03 20:48:58 +03:00
|
|
|
thread_registry.unregister_thread(&thread_info);
|
more fixes for IM to substitude mysqld_safe in startup scripts
BitKeeper/deleted/.del-thread_repository.cc~bba09f64f8cb4037:
Delete: server-tools/instance-manager/thread_repository.cc
BitKeeper/deleted/.del-thread_repository.h~e6a3b9cab7a6612a:
Delete: server-tools/instance-manager/thread_repository.h
server-tools/instance-manager/commands.cc:
All instances are guarded by default now, so we need to perform check on whether the instance is nonguarded,
rather then guarded when adding it to the list of guarded instnces.
server-tools/instance-manager/guardian.cc:
Guardian rewritten to start instances by default, and shut them down, when exiting. Behaviour of the guardian
in case of the instance crash has changed. Now it tries to restart an instance constantly in the first 2
seconds after the crash was noticed, and then it tries restart an instance once in the MONITORING_INTERVAL.
If it failed to restart instance for "restart_retry" (compiled-in value) times, guardian stops trying to
restart it.
server-tools/instance-manager/guardian.h:
Several new functions and variables declared.
server-tools/instance-manager/instance.cc:
now start doesn't call stop(), but rather tries to remove the pidfile itself
server-tools/instance-manager/instance.h:
cleanup
server-tools/instance-manager/instance_map.cc:
no more "admin" options
server-tools/instance-manager/instance_map.h:
User and password purged from instance_map options, as IM shouldn't know them
server-tools/instance-manager/instance_options.cc:
new option added -- shutdown_delay, guarded option now called nonguaded and has the opposite meaning
server-tools/instance-manager/instance_options.h:
appropriate changes, reflecting options addition/removal
server-tools/instance-manager/manager.cc:
shutdown process is complicated a bit -- at first signal thread should stop guardian, and only then the IM
itself
server-tools/instance-manager/messages.cc:
update error message
server-tools/instance-manager/options.cc:
admin user/password purged from mysqlmanager options
2005-01-31 23:54:08 +03:00
|
|
|
thread_registry.request_shutdown();
|
2004-10-23 11:32:52 +04:00
|
|
|
my_thread_end();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-02-11 14:21:59 +03:00
|
|
|
int Guardian_thread::is_stopped()
|
|
|
|
{
|
|
|
|
int var;
|
|
|
|
pthread_mutex_lock(&LOCK_guardian);
|
|
|
|
var= stopped;
|
|
|
|
pthread_mutex_unlock(&LOCK_guardian);
|
|
|
|
return var;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Initialize the list of guarded instances: loop through the Instance_map and
|
|
|
|
add all of the instances, which don't have 'nonguarded' option specified.
|
|
|
|
|
|
|
|
SYNOPSYS
|
|
|
|
Guardian_thread::init()
|
|
|
|
|
2005-02-27 18:41:34 +03:00
|
|
|
NOTE: One should always lock guardian before calling this routine.
|
|
|
|
|
2005-02-11 14:21:59 +03:00
|
|
|
RETURN
|
|
|
|
0 - ok
|
|
|
|
1 - error occured
|
|
|
|
*/
|
|
|
|
|
|
|
|
int Guardian_thread::init()
|
2004-10-26 23:22:12 +04:00
|
|
|
{
|
|
|
|
Instance *instance;
|
2004-10-27 10:21:48 +04:00
|
|
|
Instance_map::Iterator iterator(instance_map);
|
2004-10-26 23:22:12 +04:00
|
|
|
|
|
|
|
instance_map->lock();
|
2005-02-27 18:41:34 +03:00
|
|
|
/* clear the list of guarded instances */
|
|
|
|
free_root(&alloc, MYF(0));
|
|
|
|
init_alloc_root(&alloc, MEM_ROOT_BLOCK_SIZE, 0);
|
|
|
|
guarded_instances= NULL;
|
|
|
|
|
2004-12-12 20:59:15 +03:00
|
|
|
while ((instance= iterator.next()))
|
2004-10-26 23:22:12 +04:00
|
|
|
{
|
2005-02-27 18:41:34 +03:00
|
|
|
if (!(instance->options.nonguarded))
|
|
|
|
if (guard(instance, TRUE)) /* do not lock guardian */
|
|
|
|
{
|
|
|
|
instance_map->unlock();
|
2004-10-26 23:22:12 +04:00
|
|
|
return 1;
|
2005-02-27 18:41:34 +03:00
|
|
|
}
|
2004-10-26 23:22:12 +04:00
|
|
|
}
|
|
|
|
|
2005-02-27 18:41:34 +03:00
|
|
|
instance_map->unlock();
|
2004-10-26 23:22:12 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-23 11:32:52 +04:00
|
|
|
/*
|
2005-02-11 14:21:59 +03:00
|
|
|
Add instance to the Guardian list
|
2004-10-23 11:32:52 +04:00
|
|
|
|
|
|
|
SYNOPSYS
|
|
|
|
guard()
|
2004-10-27 11:01:38 +04:00
|
|
|
instance the instance to be guarded
|
2005-02-27 18:41:34 +03:00
|
|
|
nolock whether we prefer do not lock Guardian here,
|
|
|
|
but use external locking instead
|
2004-10-23 11:32:52 +04:00
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
|
2005-02-11 14:21:59 +03:00
|
|
|
The instance is added to the guarded instances list. Usually guard() is
|
|
|
|
called after we start an instance.
|
2004-10-23 11:32:52 +04:00
|
|
|
|
|
|
|
RETURN
|
|
|
|
0 - ok
|
|
|
|
1 - error occured
|
|
|
|
*/
|
|
|
|
|
2005-02-27 18:41:34 +03:00
|
|
|
int Guardian_thread::guard(Instance *instance, bool nolock)
|
2004-10-23 11:32:52 +04:00
|
|
|
{
|
2004-10-25 14:23:31 +04:00
|
|
|
LIST *node;
|
more fixes for IM to substitude mysqld_safe in startup scripts
BitKeeper/deleted/.del-thread_repository.cc~bba09f64f8cb4037:
Delete: server-tools/instance-manager/thread_repository.cc
BitKeeper/deleted/.del-thread_repository.h~e6a3b9cab7a6612a:
Delete: server-tools/instance-manager/thread_repository.h
server-tools/instance-manager/commands.cc:
All instances are guarded by default now, so we need to perform check on whether the instance is nonguarded,
rather then guarded when adding it to the list of guarded instnces.
server-tools/instance-manager/guardian.cc:
Guardian rewritten to start instances by default, and shut them down, when exiting. Behaviour of the guardian
in case of the instance crash has changed. Now it tries to restart an instance constantly in the first 2
seconds after the crash was noticed, and then it tries restart an instance once in the MONITORING_INTERVAL.
If it failed to restart instance for "restart_retry" (compiled-in value) times, guardian stops trying to
restart it.
server-tools/instance-manager/guardian.h:
Several new functions and variables declared.
server-tools/instance-manager/instance.cc:
now start doesn't call stop(), but rather tries to remove the pidfile itself
server-tools/instance-manager/instance.h:
cleanup
server-tools/instance-manager/instance_map.cc:
no more "admin" options
server-tools/instance-manager/instance_map.h:
User and password purged from instance_map options, as IM shouldn't know them
server-tools/instance-manager/instance_options.cc:
new option added -- shutdown_delay, guarded option now called nonguaded and has the opposite meaning
server-tools/instance-manager/instance_options.h:
appropriate changes, reflecting options addition/removal
server-tools/instance-manager/manager.cc:
shutdown process is complicated a bit -- at first signal thread should stop guardian, and only then the IM
itself
server-tools/instance-manager/messages.cc:
update error message
server-tools/instance-manager/options.cc:
admin user/password purged from mysqlmanager options
2005-01-31 23:54:08 +03:00
|
|
|
GUARD_NODE *content;
|
2004-10-23 11:32:52 +04:00
|
|
|
|
2004-10-25 14:23:31 +04:00
|
|
|
node= (LIST *) alloc_root(&alloc, sizeof(LIST));
|
more fixes for IM to substitude mysqld_safe in startup scripts
BitKeeper/deleted/.del-thread_repository.cc~bba09f64f8cb4037:
Delete: server-tools/instance-manager/thread_repository.cc
BitKeeper/deleted/.del-thread_repository.h~e6a3b9cab7a6612a:
Delete: server-tools/instance-manager/thread_repository.h
server-tools/instance-manager/commands.cc:
All instances are guarded by default now, so we need to perform check on whether the instance is nonguarded,
rather then guarded when adding it to the list of guarded instnces.
server-tools/instance-manager/guardian.cc:
Guardian rewritten to start instances by default, and shut them down, when exiting. Behaviour of the guardian
in case of the instance crash has changed. Now it tries to restart an instance constantly in the first 2
seconds after the crash was noticed, and then it tries restart an instance once in the MONITORING_INTERVAL.
If it failed to restart instance for "restart_retry" (compiled-in value) times, guardian stops trying to
restart it.
server-tools/instance-manager/guardian.h:
Several new functions and variables declared.
server-tools/instance-manager/instance.cc:
now start doesn't call stop(), but rather tries to remove the pidfile itself
server-tools/instance-manager/instance.h:
cleanup
server-tools/instance-manager/instance_map.cc:
no more "admin" options
server-tools/instance-manager/instance_map.h:
User and password purged from instance_map options, as IM shouldn't know them
server-tools/instance-manager/instance_options.cc:
new option added -- shutdown_delay, guarded option now called nonguaded and has the opposite meaning
server-tools/instance-manager/instance_options.h:
appropriate changes, reflecting options addition/removal
server-tools/instance-manager/manager.cc:
shutdown process is complicated a bit -- at first signal thread should stop guardian, and only then the IM
itself
server-tools/instance-manager/messages.cc:
update error message
server-tools/instance-manager/options.cc:
admin user/password purged from mysqlmanager options
2005-01-31 23:54:08 +03:00
|
|
|
content= (GUARD_NODE *) alloc_root(&alloc, sizeof(GUARD_NODE));
|
|
|
|
|
2005-02-27 18:41:34 +03:00
|
|
|
if ((!(node)) || (!(content)))
|
2004-10-25 14:23:31 +04:00
|
|
|
return 1;
|
2004-10-23 11:32:52 +04:00
|
|
|
/* we store the pointers to instances from the instance_map's MEM_ROOT */
|
more fixes for IM to substitude mysqld_safe in startup scripts
BitKeeper/deleted/.del-thread_repository.cc~bba09f64f8cb4037:
Delete: server-tools/instance-manager/thread_repository.cc
BitKeeper/deleted/.del-thread_repository.h~e6a3b9cab7a6612a:
Delete: server-tools/instance-manager/thread_repository.h
server-tools/instance-manager/commands.cc:
All instances are guarded by default now, so we need to perform check on whether the instance is nonguarded,
rather then guarded when adding it to the list of guarded instnces.
server-tools/instance-manager/guardian.cc:
Guardian rewritten to start instances by default, and shut them down, when exiting. Behaviour of the guardian
in case of the instance crash has changed. Now it tries to restart an instance constantly in the first 2
seconds after the crash was noticed, and then it tries restart an instance once in the MONITORING_INTERVAL.
If it failed to restart instance for "restart_retry" (compiled-in value) times, guardian stops trying to
restart it.
server-tools/instance-manager/guardian.h:
Several new functions and variables declared.
server-tools/instance-manager/instance.cc:
now start doesn't call stop(), but rather tries to remove the pidfile itself
server-tools/instance-manager/instance.h:
cleanup
server-tools/instance-manager/instance_map.cc:
no more "admin" options
server-tools/instance-manager/instance_map.h:
User and password purged from instance_map options, as IM shouldn't know them
server-tools/instance-manager/instance_options.cc:
new option added -- shutdown_delay, guarded option now called nonguaded and has the opposite meaning
server-tools/instance-manager/instance_options.h:
appropriate changes, reflecting options addition/removal
server-tools/instance-manager/manager.cc:
shutdown process is complicated a bit -- at first signal thread should stop guardian, and only then the IM
itself
server-tools/instance-manager/messages.cc:
update error message
server-tools/instance-manager/options.cc:
admin user/password purged from mysqlmanager options
2005-01-31 23:54:08 +03:00
|
|
|
content->instance= instance;
|
|
|
|
content->restart_counter= 0;
|
|
|
|
content->crash_moment= 0;
|
2005-02-11 14:21:59 +03:00
|
|
|
content->state= NOT_STARTED;
|
2005-05-16 01:54:02 +04:00
|
|
|
node->data= (void*) content;
|
2004-10-23 11:32:52 +04:00
|
|
|
|
2005-02-27 18:41:34 +03:00
|
|
|
if (nolock)
|
|
|
|
guarded_instances= list_add(guarded_instances, node);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pthread_mutex_lock(&LOCK_guardian);
|
|
|
|
guarded_instances= list_add(guarded_instances, node);
|
|
|
|
pthread_mutex_unlock(&LOCK_guardian);
|
|
|
|
}
|
2004-10-23 11:32:52 +04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2005-02-27 18:41:34 +03:00
|
|
|
TODO: perhaps it would make sense to create a pool of the LIST nodeents
|
2005-02-11 14:21:59 +03:00
|
|
|
and give them upon request. Now we are loosing a bit of memory when
|
2004-10-23 11:32:52 +04:00
|
|
|
guarded instance was stopped and then restarted (since we cannot free just
|
|
|
|
a piece of the MEM_ROOT).
|
|
|
|
*/
|
|
|
|
|
2004-10-26 23:22:12 +04:00
|
|
|
int Guardian_thread::stop_guard(Instance *instance)
|
2004-10-23 11:32:52 +04:00
|
|
|
{
|
2004-10-25 14:23:31 +04:00
|
|
|
LIST *node;
|
2004-10-23 11:32:52 +04:00
|
|
|
|
|
|
|
pthread_mutex_lock(&LOCK_guardian);
|
2004-10-25 14:23:31 +04:00
|
|
|
node= guarded_instances;
|
|
|
|
|
|
|
|
while (node != NULL)
|
2004-10-23 11:32:52 +04:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
We compare only pointers, as we always use pointers from the
|
|
|
|
instance_map's MEM_ROOT.
|
|
|
|
*/
|
more fixes for IM to substitude mysqld_safe in startup scripts
BitKeeper/deleted/.del-thread_repository.cc~bba09f64f8cb4037:
Delete: server-tools/instance-manager/thread_repository.cc
BitKeeper/deleted/.del-thread_repository.h~e6a3b9cab7a6612a:
Delete: server-tools/instance-manager/thread_repository.h
server-tools/instance-manager/commands.cc:
All instances are guarded by default now, so we need to perform check on whether the instance is nonguarded,
rather then guarded when adding it to the list of guarded instnces.
server-tools/instance-manager/guardian.cc:
Guardian rewritten to start instances by default, and shut them down, when exiting. Behaviour of the guardian
in case of the instance crash has changed. Now it tries to restart an instance constantly in the first 2
seconds after the crash was noticed, and then it tries restart an instance once in the MONITORING_INTERVAL.
If it failed to restart instance for "restart_retry" (compiled-in value) times, guardian stops trying to
restart it.
server-tools/instance-manager/guardian.h:
Several new functions and variables declared.
server-tools/instance-manager/instance.cc:
now start doesn't call stop(), but rather tries to remove the pidfile itself
server-tools/instance-manager/instance.h:
cleanup
server-tools/instance-manager/instance_map.cc:
no more "admin" options
server-tools/instance-manager/instance_map.h:
User and password purged from instance_map options, as IM shouldn't know them
server-tools/instance-manager/instance_options.cc:
new option added -- shutdown_delay, guarded option now called nonguaded and has the opposite meaning
server-tools/instance-manager/instance_options.h:
appropriate changes, reflecting options addition/removal
server-tools/instance-manager/manager.cc:
shutdown process is complicated a bit -- at first signal thread should stop guardian, and only then the IM
itself
server-tools/instance-manager/messages.cc:
update error message
server-tools/instance-manager/options.cc:
admin user/password purged from mysqlmanager options
2005-01-31 23:54:08 +03:00
|
|
|
if (((GUARD_NODE *) node->data)->instance == instance)
|
2004-10-23 11:32:52 +04:00
|
|
|
{
|
2004-10-25 14:23:31 +04:00
|
|
|
guarded_instances= list_delete(guarded_instances, node);
|
2004-10-23 11:32:52 +04:00
|
|
|
pthread_mutex_unlock(&LOCK_guardian);
|
|
|
|
return 0;
|
|
|
|
}
|
2004-10-25 14:23:31 +04:00
|
|
|
else
|
|
|
|
node= node->next;
|
2004-10-23 11:32:52 +04:00
|
|
|
}
|
|
|
|
pthread_mutex_unlock(&LOCK_guardian);
|
|
|
|
/* if there is nothing to delete it is also fine */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-02-11 14:21:59 +03:00
|
|
|
/*
|
|
|
|
Start Guardian shutdown. Attempt to start instances if requested.
|
more fixes for IM to substitude mysqld_safe in startup scripts
BitKeeper/deleted/.del-thread_repository.cc~bba09f64f8cb4037:
Delete: server-tools/instance-manager/thread_repository.cc
BitKeeper/deleted/.del-thread_repository.h~e6a3b9cab7a6612a:
Delete: server-tools/instance-manager/thread_repository.h
server-tools/instance-manager/commands.cc:
All instances are guarded by default now, so we need to perform check on whether the instance is nonguarded,
rather then guarded when adding it to the list of guarded instnces.
server-tools/instance-manager/guardian.cc:
Guardian rewritten to start instances by default, and shut them down, when exiting. Behaviour of the guardian
in case of the instance crash has changed. Now it tries to restart an instance constantly in the first 2
seconds after the crash was noticed, and then it tries restart an instance once in the MONITORING_INTERVAL.
If it failed to restart instance for "restart_retry" (compiled-in value) times, guardian stops trying to
restart it.
server-tools/instance-manager/guardian.h:
Several new functions and variables declared.
server-tools/instance-manager/instance.cc:
now start doesn't call stop(), but rather tries to remove the pidfile itself
server-tools/instance-manager/instance.h:
cleanup
server-tools/instance-manager/instance_map.cc:
no more "admin" options
server-tools/instance-manager/instance_map.h:
User and password purged from instance_map options, as IM shouldn't know them
server-tools/instance-manager/instance_options.cc:
new option added -- shutdown_delay, guarded option now called nonguaded and has the opposite meaning
server-tools/instance-manager/instance_options.h:
appropriate changes, reflecting options addition/removal
server-tools/instance-manager/manager.cc:
shutdown process is complicated a bit -- at first signal thread should stop guardian, and only then the IM
itself
server-tools/instance-manager/messages.cc:
update error message
server-tools/instance-manager/options.cc:
admin user/password purged from mysqlmanager options
2005-01-31 23:54:08 +03:00
|
|
|
|
2005-02-11 14:21:59 +03:00
|
|
|
SYNOPSYS
|
|
|
|
stop_instances()
|
|
|
|
stop_instances_arg whether we should stop instances at shutdown
|
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
|
|
|
|
Loops through the guarded_instances list and prepares them for shutdown.
|
|
|
|
If stop_instances was requested, we need to issue a stop command and change
|
|
|
|
the state accordingly. Otherwise we could simply delete an entry.
|
|
|
|
NOTE: Guardian should be locked by the calling function
|
|
|
|
|
|
|
|
RETURN
|
|
|
|
0 - ok
|
|
|
|
1 - error occured
|
|
|
|
*/
|
|
|
|
|
|
|
|
int Guardian_thread::stop_instances(bool stop_instances_arg)
|
|
|
|
{
|
|
|
|
LIST *node;
|
|
|
|
node= guarded_instances;
|
|
|
|
while (node != NULL)
|
more fixes for IM to substitude mysqld_safe in startup scripts
BitKeeper/deleted/.del-thread_repository.cc~bba09f64f8cb4037:
Delete: server-tools/instance-manager/thread_repository.cc
BitKeeper/deleted/.del-thread_repository.h~e6a3b9cab7a6612a:
Delete: server-tools/instance-manager/thread_repository.h
server-tools/instance-manager/commands.cc:
All instances are guarded by default now, so we need to perform check on whether the instance is nonguarded,
rather then guarded when adding it to the list of guarded instnces.
server-tools/instance-manager/guardian.cc:
Guardian rewritten to start instances by default, and shut them down, when exiting. Behaviour of the guardian
in case of the instance crash has changed. Now it tries to restart an instance constantly in the first 2
seconds after the crash was noticed, and then it tries restart an instance once in the MONITORING_INTERVAL.
If it failed to restart instance for "restart_retry" (compiled-in value) times, guardian stops trying to
restart it.
server-tools/instance-manager/guardian.h:
Several new functions and variables declared.
server-tools/instance-manager/instance.cc:
now start doesn't call stop(), but rather tries to remove the pidfile itself
server-tools/instance-manager/instance.h:
cleanup
server-tools/instance-manager/instance_map.cc:
no more "admin" options
server-tools/instance-manager/instance_map.h:
User and password purged from instance_map options, as IM shouldn't know them
server-tools/instance-manager/instance_options.cc:
new option added -- shutdown_delay, guarded option now called nonguaded and has the opposite meaning
server-tools/instance-manager/instance_options.h:
appropriate changes, reflecting options addition/removal
server-tools/instance-manager/manager.cc:
shutdown process is complicated a bit -- at first signal thread should stop guardian, and only then the IM
itself
server-tools/instance-manager/messages.cc:
update error message
server-tools/instance-manager/options.cc:
admin user/password purged from mysqlmanager options
2005-01-31 23:54:08 +03:00
|
|
|
{
|
2005-02-11 14:21:59 +03:00
|
|
|
if (!stop_instances_arg)
|
more fixes for IM to substitude mysqld_safe in startup scripts
BitKeeper/deleted/.del-thread_repository.cc~bba09f64f8cb4037:
Delete: server-tools/instance-manager/thread_repository.cc
BitKeeper/deleted/.del-thread_repository.h~e6a3b9cab7a6612a:
Delete: server-tools/instance-manager/thread_repository.h
server-tools/instance-manager/commands.cc:
All instances are guarded by default now, so we need to perform check on whether the instance is nonguarded,
rather then guarded when adding it to the list of guarded instnces.
server-tools/instance-manager/guardian.cc:
Guardian rewritten to start instances by default, and shut them down, when exiting. Behaviour of the guardian
in case of the instance crash has changed. Now it tries to restart an instance constantly in the first 2
seconds after the crash was noticed, and then it tries restart an instance once in the MONITORING_INTERVAL.
If it failed to restart instance for "restart_retry" (compiled-in value) times, guardian stops trying to
restart it.
server-tools/instance-manager/guardian.h:
Several new functions and variables declared.
server-tools/instance-manager/instance.cc:
now start doesn't call stop(), but rather tries to remove the pidfile itself
server-tools/instance-manager/instance.h:
cleanup
server-tools/instance-manager/instance_map.cc:
no more "admin" options
server-tools/instance-manager/instance_map.h:
User and password purged from instance_map options, as IM shouldn't know them
server-tools/instance-manager/instance_options.cc:
new option added -- shutdown_delay, guarded option now called nonguaded and has the opposite meaning
server-tools/instance-manager/instance_options.h:
appropriate changes, reflecting options addition/removal
server-tools/instance-manager/manager.cc:
shutdown process is complicated a bit -- at first signal thread should stop guardian, and only then the IM
itself
server-tools/instance-manager/messages.cc:
update error message
server-tools/instance-manager/options.cc:
admin user/password purged from mysqlmanager options
2005-01-31 23:54:08 +03:00
|
|
|
{
|
2005-02-11 14:21:59 +03:00
|
|
|
/* just forget about an instance */
|
|
|
|
guarded_instances= list_delete(guarded_instances, node);
|
|
|
|
/*
|
|
|
|
This should still work fine, as we have only removed the
|
|
|
|
node from the list. The pointer to the next one is still valid
|
|
|
|
*/
|
|
|
|
node= node->next;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GUARD_NODE *current_node= (GUARD_NODE *) node->data;
|
|
|
|
/*
|
|
|
|
If instance is running or was running (and now probably hanging),
|
|
|
|
request stop.
|
|
|
|
*/
|
|
|
|
if (current_node->instance->is_running() ||
|
|
|
|
(current_node->state == STARTED))
|
|
|
|
{
|
|
|
|
current_node->state= STOPPING;
|
|
|
|
current_node->last_checked= time(NULL);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
/* otherwise remove it from the list */
|
|
|
|
guarded_instances= list_delete(guarded_instances, node);
|
|
|
|
/* But try to kill it anyway. Just in case */
|
|
|
|
current_node->instance->kill_instance(SIGTERM);
|
|
|
|
node= node->next;
|
more fixes for IM to substitude mysqld_safe in startup scripts
BitKeeper/deleted/.del-thread_repository.cc~bba09f64f8cb4037:
Delete: server-tools/instance-manager/thread_repository.cc
BitKeeper/deleted/.del-thread_repository.h~e6a3b9cab7a6612a:
Delete: server-tools/instance-manager/thread_repository.h
server-tools/instance-manager/commands.cc:
All instances are guarded by default now, so we need to perform check on whether the instance is nonguarded,
rather then guarded when adding it to the list of guarded instnces.
server-tools/instance-manager/guardian.cc:
Guardian rewritten to start instances by default, and shut them down, when exiting. Behaviour of the guardian
in case of the instance crash has changed. Now it tries to restart an instance constantly in the first 2
seconds after the crash was noticed, and then it tries restart an instance once in the MONITORING_INTERVAL.
If it failed to restart instance for "restart_retry" (compiled-in value) times, guardian stops trying to
restart it.
server-tools/instance-manager/guardian.h:
Several new functions and variables declared.
server-tools/instance-manager/instance.cc:
now start doesn't call stop(), but rather tries to remove the pidfile itself
server-tools/instance-manager/instance.h:
cleanup
server-tools/instance-manager/instance_map.cc:
no more "admin" options
server-tools/instance-manager/instance_map.h:
User and password purged from instance_map options, as IM shouldn't know them
server-tools/instance-manager/instance_options.cc:
new option added -- shutdown_delay, guarded option now called nonguaded and has the opposite meaning
server-tools/instance-manager/instance_options.h:
appropriate changes, reflecting options addition/removal
server-tools/instance-manager/manager.cc:
shutdown process is complicated a bit -- at first signal thread should stop guardian, and only then the IM
itself
server-tools/instance-manager/messages.cc:
update error message
server-tools/instance-manager/options.cc:
admin user/password purged from mysqlmanager options
2005-01-31 23:54:08 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2005-02-27 18:41:34 +03:00
|
|
|
|
|
|
|
|
2005-08-05 14:35:30 +04:00
|
|
|
void Guardian_thread::lock()
|
2005-02-27 18:41:34 +03:00
|
|
|
{
|
2005-07-20 10:55:40 -05:00
|
|
|
pthread_mutex_lock(&LOCK_guardian);
|
2005-02-27 18:41:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-08-05 14:35:30 +04:00
|
|
|
void Guardian_thread::unlock()
|
2005-02-27 18:41:34 +03:00
|
|
|
{
|
2005-07-20 10:55:40 -05:00
|
|
|
pthread_mutex_unlock(&LOCK_guardian);
|
2005-02-27 18:41:34 +03:00
|
|
|
}
|