List:Commits« Previous MessageNext Message »
From:Alfranio Correia Date:June 20 2011 10:52am
Subject:bzr commit into mysql-next-mr-wl5569 branch (alfranio.correia:3310)
View as plain text  
#At file:///home/acorreia/workspace.oracle/repository.mysql/bzrwork/wl-5569/mysql-next-mr-wl5569/ based on revid:andrei.elkin@stripped

 3310 Alfranio Correia	2011-06-20
      Fixed valgrind errors.
      
      Slave_job_group was silently being cast to LOG_POS_COORD while calling
      sort_dynamic(&above_lwm_jobs, (qsort_cmp) mts_event_coord_cmp) and by
      consequence mts_event_coord_cmp(LOG_POS_COORD *, LOG_POS_COORD *).
      
      This had two problems:
      
        . The first two entries in the Slave_job_group were not a pointer to
          a char * and my_offset.
      
        . Even if the first two entries were char * and my_offset, such
          casting could lead to alignment problems.
      
      To fix the problem, we avoid this casting.

    modified:
      sql/rpl_rli_pdb.h
      sql/rpl_slave.cc
=== modified file 'sql/rpl_rli_pdb.h'
--- a/sql/rpl_rli_pdb.h	2011-06-18 18:58:21 +0000
+++ b/sql/rpl_rli_pdb.h	2011-06-20 10:52:44 +0000
@@ -119,9 +119,7 @@ public:
 typedef struct st_slave_job_group
 {
   char *group_master_log_name; // (actually redundant)
-  my_off_t master_log_pos;       // B-event log_pos
   my_off_t group_master_log_pos; // T-event lop_pos filled by W for CheckPoint
-  my_off_t group_relay_log_pos;  // filled by W
 
   /* 
      When RL name changes C allocates and fill in a new name of RL,
@@ -133,10 +131,13 @@ typedef struct st_slave_job_group
      Freeing unless NULL is left to C at CheckPoint.
   */
   char     *group_relay_log_name; // The value is last seen relay-log 
+  my_off_t group_relay_log_pos;  // filled by W
+
   ulong worker_id;
   Slave_worker *worker;
   ulonglong total_seqno;
 
+  my_off_t master_log_pos;       // B-event log_pos
   /* checkpoint coord are reset by CP and rotate:s */
   uint  checkpoint_seqno;
   my_off_t checkpoint_log_pos; // T-event lop_pos filled by W for CheckPoint

=== modified file 'sql/rpl_slave.cc'
--- a/sql/rpl_slave.cc	2011-06-19 08:04:19 +0000
+++ b/sql/rpl_slave.cc	2011-06-20 10:52:44 +0000
@@ -192,6 +192,8 @@ static int terminate_slave_thread(THD *t
                                   bool skip_lock);
 static bool check_io_slave_killed(THD *thd, Master_info *mi, const char *info);
 int slave_worker_exec_job(Slave_worker * w, Relay_log_info *rli);
+static int mts_event_coord_cmp(LOG_POS_COORD *id1, LOG_POS_COORD *id2);
+static int mts_event_job_cmp(Slave_job_group *id1, Slave_job_group *id2);
 
 /*
   Find out which replications threads are running
@@ -3837,16 +3839,23 @@ int mts_event_coord_cmp(LOG_POS_COORD *i
          (poscmp  < 0  ? -1 : (poscmp  > 0  ?  1 : 0))));
 }
 
+int mts_event_job_cmp(Slave_job_group *id1, Slave_job_group *id2)
+{
+  longlong filecmp= strcmp(id1->checkpoint_log_name, id2->checkpoint_log_name);
+  longlong poscmp= id1->checkpoint_log_pos - id2->checkpoint_log_pos;
+  return (filecmp < 0  ? -1 : (filecmp > 0  ?  1 :
+         (poscmp  < 0  ? -1 : (poscmp  > 0  ?  1 : 0))));
+}
+
 bool mts_recovery_groups(Relay_log_info *rli, MY_BITMAP *groups)
 { 
-  Log_event *ev= NULL; // , *desc= NULL;
+  Log_event *ev= NULL;
   const char *log_name= NULL;
   const char *errmsg= NULL;
   bool error= FALSE;
-  DYNAMIC_ARRAY above_lwm_jobs;
   bool curr_group_seen_begin= FALSE;
+  DYNAMIC_ARRAY above_lwm_jobs;
   Slave_job_group job_worker;
-  Slave_job_group job_file;
   IO_CACHE log;
   File file;
 
@@ -3871,14 +3880,19 @@ bool mts_recovery_groups(Relay_log_info
     Slave_worker *worker=
       Rpl_info_factory::create_worker(opt_worker_repository_id, id, rli);
     worker->init_info();
-    retrieve_job(worker, job_file);
     LOG_POS_COORD w_last= {worker->group_master_log_name, worker->group_master_log_pos};
     if (mts_event_coord_cmp(&w_last, &cp) > 0)
     {
       /*
         Inserts information into a dynamic array for further processing.
+        The jobs/workers are ordered by the last checkpoint positions
+        workers have seen.
       */
-      insert_dynamic(&above_lwm_jobs, (uchar*) &job_file);
+      job_worker.worker= worker;
+      job_worker.checkpoint_log_pos= worker->checkpoint_master_log_pos;
+      job_worker.checkpoint_log_name= worker->checkpoint_master_log_name;
+
+      insert_dynamic(&above_lwm_jobs, (uchar*) &job_worker);
     }
     else
     {
@@ -3889,9 +3903,13 @@ bool mts_recovery_groups(Relay_log_info
       worker->end_info();
       delete worker;
     }
-  };
+  }
 
-  sort_dynamic(&above_lwm_jobs, (qsort_cmp) mts_event_coord_cmp);
+  /*
+    This sorts the array by the last checkpoint positions workers have seen
+    and is required in the next recovery phase to compute shift bits.
+  */
+  sort_dynamic(&above_lwm_jobs, (qsort_cmp) mts_event_job_cmp);
   /*
     In what follows, the group Recovery Bitmap is constructed.
 
@@ -4393,7 +4411,7 @@ void slave_stop_workers(Relay_log_info *
 
   for (i= rli->workers.elements - 1; i >= 0; i--)
   {
-    Slave_worker *w;
+    Slave_worker *w= NULL;
     get_dynamic((DYNAMIC_ARRAY*)&rli->workers, (uchar*) &w, i);
 
     mysql_mutex_lock(&w->jobs_lock);


Attachment: [text/bzr-bundle] bzr/alfranio.correia@oracle.com-20110620105244-njmxh5t2pr02fv9f.bundle
Thread
bzr commit into mysql-next-mr-wl5569 branch (alfranio.correia:3310) Alfranio Correia20 Jun