Commit e88867f7 authored by unknown's avatar unknown
Browse files

Merge bk-internal.mysql.com:/home/bk/mysql-5.1-runtime

into  alik.:/mnt/raid/alik/MySQL/devel/5.1-rt-bug17486

parents 5aa81b56 f0ad68c9
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -14,8 +14,6 @@
#events                   : BUG#17619 2006-02-21 andrey  Race conditions
#events_scheduling        : BUG#19170 2006-04-26 andrey  Test case of 19170 fails on some platforms. Has to be checked.
im_options                : Bug#20294 2006-07-24 stewart   Instance manager test im_options fails randomly
#im_life_cycle             : Bug#20368 2006-06-10 alik    im_life_cycle test fails
im_daemon_life_cycle     : BUG#22379 2006-09-15 ingo    im_daemon_life_cycle.test fails on merge of 5.1 -> 5.1-engines
im_instance_conf         : BUG#20294 2006-09-16 ingo    Instance manager test im_instance_conf fails randomly
concurrent_innodb        : BUG#21579 2006-08-11 mleich innodb_concurrent random failures with varying differences
ndb_autodiscover         : BUG#18952 2006-02-16 jmiller Needs to be fixed w.r.t binlog
+7 −1
Original line number Diff line number Diff line
@@ -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.");
}


+34 −9
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@
#include "mysql_manager_error.h"
#include "portability.h"
#include "priv.h"
#include "thread_registry.h"


const LEX_STRING
@@ -44,7 +45,8 @@ static const int INSTANCE_NAME_PREFIX_LEN= Instance::DFLT_INSTANCE_NAME.length;


static void start_and_monitor_instance(Instance_options *old_instance_options,
                                       Instance_map *instance_map);
                                       Instance_map *instance_map,
                                       Thread_registry *thread_registry);

#ifndef __WIN__
typedef pid_t My_process_info;
@@ -63,7 +65,8 @@ pthread_handler_t proxy(void *arg)
{
  Instance *instance= (Instance *) arg;
  start_and_monitor_instance(&instance->options,
                             instance->get_map());
                             instance->get_map(),
                             &instance->thread_registry);
  return 0;
}

@@ -99,6 +102,7 @@ static int wait_process(My_process_info *pi)
    thread, but we don't know this one). Or we could use waitpid(), but
    couldn't use wait(), because it could return in any wait() in the program.
  */

  if (linuxthreads)
    wait(NULL);                               /* LinuxThreads were detected */
  else
@@ -239,11 +243,28 @@ static int start_process(Instance_options *instance_options,
*/

static void start_and_monitor_instance(Instance_options *old_instance_options,
                                       Instance_map *instance_map)
                                       Instance_map *instance_map,
                                       Thread_registry *thread_registry)
{
  Instance_name instance_name(&old_instance_options->instance_name);
  Instance *current_instance;
  My_process_info process_info;
  Thread_info thread_info(pthread_self(), FALSE);

  log_info("Monitoring thread (instance: '%s'): started.",
           (const char *) instance_name.get_c_str());

  if (!old_instance_options->nonguarded)
  {
    /*
      Register thread in Thread_registry to wait for it to stop on shutdown
      only if instance is nuarded. If instance is guarded, the thread will not
      finish, because nonguarded instances are not stopped on shutdown.
    */

    thread_registry->register_thread(&thread_info);
    my_thread_init();
  }

  /*
    Lock instance map to guarantee that no instances are deleted during
@@ -280,7 +301,14 @@ static void start_and_monitor_instance(Instance_options *old_instance_options,

  instance_map->unlock();

  return;
  if (!old_instance_options->nonguarded)
  {
    thread_registry->unregister_thread(&thread_info);
    my_thread_end();
  }

  log_info("Monitoring thread (instance: '%s'): finished.",
           (const char *) instance_name.get_c_str());
}


@@ -343,10 +371,6 @@ int Instance::start()
  {
    remove_pid();

    /*
      No need to monitor this thread in the Thread_registry, as all
      instances are to be stopped during shutdown.
    */
    pthread_t proxy_thd_id;
    pthread_attr_t proxy_thd_attr;
    int rc;
@@ -404,7 +428,8 @@ void Instance::set_crash_flag_n_wake_all()



Instance::Instance(): crashed(FALSE), configured(FALSE)
Instance::Instance(Thread_registry &thread_registry_arg):
  crashed(FALSE), configured(FALSE), thread_registry(thread_registry_arg)
{
  pthread_mutex_init(&LOCK_instance, 0);
  pthread_cond_init(&COND_instance_stopped, 0);
+3 −1
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@
#endif

class Instance_map;
class Thread_registry;


/*
@@ -87,7 +88,7 @@ class Instance
  static bool is_mysqld_compatible_name(const LEX_STRING *name);

public:
  Instance();
  Instance(Thread_registry &thread_registry_arg);

  ~Instance();
  int init(const LEX_STRING *name_arg);
@@ -120,6 +121,7 @@ class Instance
public:
  enum { DEFAULT_SHUTDOWN_DELAY= 35 };
  Instance_options options;
  Thread_registry &thread_registry;

private:
  /* This attributes is a flag, specifies if the instance has been crashed. */
+6 −4
Original line number Diff line number Diff line
@@ -169,7 +169,7 @@ int Instance_map::process_one_option(const LEX_STRING *group,
  if (!(instance= (Instance *) hash_search(&hash, (byte *) group->str,
                                           group->length)))
  {
    if (!(instance= new Instance()))
    if (!(instance= new Instance(thread_registry)))
      return 1;

    if (instance->init(group) || add_instance(instance))
@@ -213,8 +213,10 @@ int Instance_map::process_one_option(const LEX_STRING *group,
}


Instance_map::Instance_map(const char *default_mysqld_path_arg):
mysqld_path(default_mysqld_path_arg)
Instance_map::Instance_map(const char *default_mysqld_path_arg,
                           Thread_registry &thread_registry_arg):
  mysqld_path(default_mysqld_path_arg),
  thread_registry(thread_registry_arg)
{
  pthread_mutex_init(&LOCK_instance_map, 0);
}
@@ -333,7 +335,7 @@ int Instance_map::remove_instance(Instance *instance)
int Instance_map::create_instance(const LEX_STRING *instance_name,
                                  const Named_value_arr *options)
{
  Instance *instance= new Instance();
  Instance *instance= new Instance(thread_registry);

  if (!instance)
  {
Loading