List:Commits« Previous MessageNext Message »
From:Andrei Elkin Date:September 20 2010 3:08pm
Subject:bzr commit into mysql-next-mr-rpl-merge branch (aelkin:3194) WL#5563
View as plain text  
#At file:///home/andrei/MySQL/BZR/2a-23May/WL/mysql-next-mr-wl5563-labs/ based on revid:aelkin@stripped

 3194 Andrei Elkin	2010-09-20
      wl#5563
      
      stop slave handling is corrected.
      Workers clean up their assignement to decrement rli->pending_jobs as well.
      The latter counter is checked on zero to signal to the SQL thread by the last remained worker to clean up remained worker areas

    modified:
      sql/rpl_slave.cc
=== modified file 'sql/rpl_slave.cc'
--- a/sql/rpl_slave.cc	2010-09-17 22:28:23 +0000
+++ b/sql/rpl_slave.cc	2010-09-20 15:07:56 +0000
@@ -3433,6 +3433,7 @@ pthread_handler_t handle_slave_worker(vo
   mysql_mutex_unlock(&LOCK_thread_count);
 
   DBUG_ASSERT(thd->is_slave_error == 0);
+
   while (!thd->killed)
   {
       error= slave_worker_exec_job(w, rli);
@@ -3440,7 +3441,9 @@ pthread_handler_t handle_slave_worker(vo
  
 err:
   mysql_mutex_lock(&rli->pending_jobs_lock);
-  rli->pending_jobs= 0;
+  rli->pending_jobs--;
+  if (rli->pending_jobs == 0)
+    mysql_cond_signal(&rli->pending_jobs_cond);
   mysql_mutex_unlock(&rli->pending_jobs_lock);
   mysql_cond_signal(&rli->pending_jobs_cond); // informing the parent
   mysql_mutex_lock(&LOCK_thread_count);
@@ -3508,69 +3511,41 @@ err:
 /* 
    Worker threads ends one-by-one with synch through rli->pending_jobs
 */
-#if 0
 void slave_stop_workers(Relay_log_info *rli)
 {
   int i;
-  int wait_times= rli->workers.elements;
 
   mysql_mutex_lock(&rli->pending_jobs_lock);
+  rli->pending_jobs += rli->workers.elements;
 
   for (i= rli->workers.elements - 1; i >= 0; i--)
   {
-    struct slave_worker *w;
+    Slave_worker *w;
     get_dynamic((DYNAMIC_ARRAY*)&rli->workers, (uchar*) &w, i);
     mysql_mutex_lock(&w->thd->LOCK_thd_data);
     w->thd->awake(THD::KILL_QUERY);
     mysql_mutex_unlock(&w->thd->LOCK_thd_data);
   }
   
-  while (wait_times > 0)
+  while (rli->pending_jobs > 0)
   {
-    thd_proc_info(rli->sql_thd, "Waiting for workers to exit");
+    thd_proc_info(rli->info_thd, "Waiting for workers to exit");
     mysql_cond_wait(&rli->pending_jobs_cond, &rli->pending_jobs_lock);
-    wait_times--;
   }
 
   mysql_mutex_unlock(&rli->pending_jobs_lock);
 
   for (i= rli->workers.elements - 1; i >= 0; i--)
   {
-    struct slave_worker *w;
-    get_dynamic((DYNAMIC_ARRAY*)&rli->workers, (uchar*) &w, i);
-    mysql_mutex_destroy(&w->jobs_lock);
-    mysql_cond_destroy(&w->jobs_cond);
-    free_root(&w->mem_root, MYF(0));
-    delete_dynamic_element(&rli->workers, i);
-    delete w;
-  }
-  destroy_hash_worker();
-}
-#endif
-void slave_stop_workers(Relay_log_info *rli)
-{
-  int i;
-  for (i= rli->workers.elements - 1; i >= 0; i--)
-  {
     Slave_worker *w;
     get_dynamic((DYNAMIC_ARRAY*)&rli->workers, (uchar*) &w, i);
-    mysql_mutex_lock(&rli->pending_jobs_lock);
-    rli->pending_jobs= 1;
-    while (rli->pending_jobs > 0)
-    {
-      thd_proc_info(rli->info_thd, "Waiting for worker to exit");
-      mysql_mutex_lock(&w->thd->LOCK_thd_data);
-      w->thd->awake(THD::KILL_QUERY);
-      mysql_mutex_unlock(&w->thd->LOCK_thd_data);
-      mysql_cond_wait(&rli->pending_jobs_cond, &rli->pending_jobs_lock);
-    }
-    mysql_mutex_unlock(&rli->pending_jobs_lock);
     mysql_mutex_destroy(&w->jobs_lock);
     mysql_cond_destroy(&w->jobs_cond);
     free_root(&w->mem_root, MYF(0));
     delete_dynamic_element(&rli->workers, i);
     delete w;
   }
+  destroy_hash_workers();
 }
 
 /**


Attachment: [text/bzr-bundle] bzr/aelkin@mysql.com-20100920150756-f2hl1vep0i10ghhb.bundle
Thread
bzr commit into mysql-next-mr-rpl-merge branch (aelkin:3194) WL#5563Andrei Elkin20 Sep