List:Commits« Previous MessageNext Message »
From:Petr Chardin Date:February 14 2006 2:57am
Subject:bk commit into 5.0 tree (petr:1.2000)
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of cps. When cps does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.2000 06/02/14 04:57:38 petr@stripped +4 -0
  Fix race condition: instance map wasn't locked for the
  duration of the whole 'flush instances'. As a consequence,
  it was possible to query instance map, while it is in the
  inconsistent state.

  server-tools/instance-manager/manager.cc
    1.31 06/02/14 04:57:35 petr@stripped +2 -0
    lock instance map before initing guardian

  server-tools/instance-manager/instance_map.h
    1.18 06/02/14 04:57:35 petr@stripped +1 -1
    add parameter to find()

  server-tools/instance-manager/instance_map.cc
    1.25 06/02/14 04:57:35 petr@stripped +8 -6
    Eliminate race condition: lock instance map and guardian
    for the duration of the whole "FLUSH INSTANCES" execution.

  server-tools/instance-manager/guardian.cc
    1.20 06/02/14 04:57:35 petr@stripped +2 -3
    do not lock instance map in Guardian_thread::init()

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	petr
# Host:	outpost.site
# Root:	/home/cps/mysql/devel/im/5.0-im-fix-race

--- 1.30/server-tools/instance-manager/manager.cc	2005-10-28 14:29:37 +04:00
+++ 1.31/server-tools/instance-manager/manager.cc	2006-02-14 04:57:35 +03:00
@@ -208,11 +208,13 @@
   shutdown_complete= FALSE;
 
   /* init list of guarded instances */
+  instance_map.lock();
   guardian_thread.lock();
 
   guardian_thread.init();
 
   guardian_thread.unlock();
+  instance_map.unlock();
 
   /*
     After the list of guarded instances have been initialized,

--- 1.19/server-tools/instance-manager/guardian.cc	2005-10-08 18:39:39 +04:00
+++ 1.20/server-tools/instance-manager/guardian.cc	2006-02-14 04:57:35 +03:00
@@ -244,7 +244,8 @@
   SYNOPSYS
     Guardian_thread::init()
 
-  NOTE: One should always lock guardian before calling this routine.
+  NOTE: One should always lock instance map and guardian before
+        calling this routine! (in this order)
 
   RETURN
     0 - ok
@@ -256,7 +257,6 @@
   Instance *instance;
   Instance_map::Iterator iterator(instance_map);
 
-  instance_map->lock();
   /* clear the list of guarded instances */
   free_root(&alloc, MYF(0));
   init_alloc_root(&alloc, MEM_ROOT_BLOCK_SIZE, 0);
@@ -272,7 +272,6 @@
       }
   }
 
-  instance_map->unlock();
   return 0;
 }
 

--- 1.24/server-tools/instance-manager/instance_map.cc	2005-09-23 22:28:46 +04:00
+++ 1.25/server-tools/instance-manager/instance_map.cc	2006-02-14 04:57:35 +03:00
@@ -88,7 +88,7 @@
       ((my_isdigit(default_charset_info, group[sizeof prefix]))
        || group[sizeof(prefix)] == '\0'))
     {
-      if ((instance= map->find(group, strlen(group))) == NULL)
+      if ((instance= map->find(group, strlen(group), FALSE)) == NULL)
       {
         if ((instance= new Instance) == 0)
           goto err;
@@ -149,15 +149,15 @@
 {
   int rc;
 
-  guardian->lock();
   pthread_mutex_lock(&LOCK_instance_map);
+  guardian->lock();
   hash_free(&hash);
   hash_init(&hash, default_charset_info, START_HASH_SIZE, 0, 0,
             get_instance_key, delete_instance, 0);
-  pthread_mutex_unlock(&LOCK_instance_map);
   rc= load();
   guardian->init();
   guardian->unlock();
+  pthread_mutex_unlock(&LOCK_instance_map);
   return rc;
 }
 
@@ -169,12 +169,14 @@
 
 
 Instance *
-Instance_map::find(const char *name, uint name_len)
+Instance_map::find(const char *name, uint name_len, bool lock)
 {
   Instance *instance;
-  pthread_mutex_lock(&LOCK_instance_map);
+  if (lock)
+    pthread_mutex_lock(&LOCK_instance_map);
   instance= (Instance *) hash_search(&hash, (byte *) name, name_len);
-  pthread_mutex_unlock(&LOCK_instance_map);
+  if (lock)
+    pthread_mutex_unlock(&LOCK_instance_map);
   return instance;
 }
 

--- 1.17/server-tools/instance-manager/instance_map.h	2005-09-23 22:28:47 +04:00
+++ 1.18/server-tools/instance-manager/instance_map.h	2006-02-14 04:57:35 +03:00
@@ -57,7 +57,7 @@
   friend class Iterator;
 public:
   /* returns a pointer to the instance or NULL, if there is no such instance */
-  Instance *find(const char *name, uint name_len);
+  Instance *find(const char *name, uint name_len, bool lock= TRUE);
 
   int flush_instances();
   void lock();
Thread
bk commit into 5.0 tree (petr:1.2000)Petr Chardin14 Feb