List:Commits« Previous MessageNext Message »
From:Alfranio Correia Date:June 22 2011 5:54pm
Subject:bzr commit into mysql-next-mr-wl5569 branch (alfranio.correia:3315)
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

 3315 Alfranio Correia	2011-06-22
      Fixed how mts copes with recovery.

    modified:
      sql/log_event.cc
      sql/rpl_rli.cc
      sql/rpl_rli.h
      sql/rpl_slave.cc
=== modified file 'sql/log_event.cc'
--- a/sql/log_event.cc	2011-06-21 14:05:32 +0000
+++ b/sql/log_event.cc	2011-06-22 17:54:23 +0000
@@ -2864,19 +2864,14 @@ int Log_event::apply_event(Relay_log_inf
   {
     bool skip= bitmap_is_set(&c_rli->recovery_groups, c_rli->mts_recovery_index);
 
-    if (ends_group()) // TODO: || ! seen_begin
-    {
-      c_rli->mts_recovery_index++;
-      if (--c_rli->mts_recovery_group_cnt == 0)
-      {
-        c_rli->recovery_parallel_workers= c_rli->slave_parallel_workers;
-        c_rli->mts_recovery_index= 0;
-      }
-    }
     if (skip)
+    {
       DBUG_RETURN(0);
-    else 
+    }
+    else
+    { 
       DBUG_RETURN(do_apply_event(rli));
+    }
   }
 
   if (!(parallel= rli->is_parallel_exec()) ||

=== modified file 'sql/rpl_rli.cc'
--- a/sql/rpl_rli.cc	2011-06-18 18:58:21 +0000
+++ b/sql/rpl_rli.cc	2011-06-22 17:54:23 +0000
@@ -75,7 +75,8 @@ Relay_log_info::Relay_log_info(bool is_s
    this_worker(NULL), slave_parallel_workers(0),
    recovery_parallel_workers(0),
    checkpoint_group(mts_checkpoint_group), mts_recovery_group_cnt(0),
-   mts_recovery_index(0), mts_group_status(MTS_NOT_IN_GROUP),
+   mts_recovery_index(0), mts_recovery_group_seen_begin(0),
+   mts_group_status(MTS_NOT_IN_GROUP),
    sql_delay(0), sql_delay_end(0), m_flags(0)
 {
   DBUG_ENTER("Relay_log_info::Relay_log_info");

=== modified file 'sql/rpl_rli.h'
--- a/sql/rpl_rli.h	2011-06-14 18:23:13 +0000
+++ b/sql/rpl_rli.h	2011-06-22 17:54:23 +0000
@@ -472,6 +472,7 @@ public:
   MY_BITMAP recovery_groups;  // bitmap used during recovery
   ulong mts_recovery_group_cnt; // number of groups to execute at recovery
   ulong mts_recovery_index;     // running index of recoverable groups
+  bool mts_recovery_group_seen_begin;
   /*
     temporary tables are held by Coordinator though are created and dropped
     explicilty by Workers. The following lock has to be taken by either party

=== modified file 'sql/rpl_slave.cc'
--- a/sql/rpl_slave.cc	2011-06-21 14:05:32 +0000
+++ b/sql/rpl_slave.cc	2011-06-22 17:54:23 +0000
@@ -2724,6 +2724,7 @@ int apply_event_and_update_pos(Log_event
   int exec_res= 0;
   bool skip_event= FALSE;
   Log_event *ev= *ptr_ev;
+  Log_event::enum_skip_reason reason= Log_event::EVENT_SKIP_NOT;
 
   DBUG_ENTER("apply_event_and_update_pos");
 
@@ -2766,7 +2767,18 @@ int apply_event_and_update_pos(Log_event
     ev->when= my_time(0);
   ev->thd = thd; // because up to this point, ev->thd == 0
 
-  int reason= ev->shall_skip(rli);
+  if (!(rli->is_mts_recovery() && bitmap_is_set(&rli->recovery_groups,
+                                                rli->mts_recovery_index)))
+  {
+    reason= ev->shall_skip(rli);
+  }
+
+  DBUG_PRINT("Mts", ("Mts is recovering %d, number of bits set %d, "
+             "bitmap is set %d, index %lu.",
+             rli->is_mts_recovery(), bitmap_bits_set(&rli->recovery_groups),
+             bitmap_is_set(&rli->recovery_groups, rli->mts_recovery_index),
+             rli->mts_recovery_index));
+
   if (reason == Log_event::EVENT_SKIP_COUNT)
   {
     sql_slave_skip_counter= --rli->slave_skip_counter;
@@ -2777,6 +2789,7 @@ int apply_event_and_update_pos(Log_event
     // Sleeps if needed, and unlocks rli->data_lock.
     if (sql_delay_event(ev, thd, rli))
       DBUG_RETURN(0);
+
     exec_res= ev->apply_event(rli);
 
     if (!exec_res && (ev->worker != rli))
@@ -2858,7 +2871,25 @@ int apply_event_and_update_pos(Log_event
   }
   else
     mysql_mutex_unlock(&rli->data_lock);
-
+ 
+  if (rli->is_mts_recovery())
+  {
+    if (ev->starts_group())
+    {
+      rli->mts_recovery_group_seen_begin= TRUE;
+    }
+    if (ev->ends_group() || !rli->mts_recovery_group_seen_begin)
+    {
+      rli->mts_recovery_index++;
+      if (--rli->mts_recovery_group_cnt == 0)
+      {
+        rli->recovery_parallel_workers= rli->slave_parallel_workers;
+        rli->mts_recovery_index= 0;
+      }
+      rli->mts_recovery_group_seen_begin= FALSE;
+    }
+  }
+ 
   DBUG_PRINT("info", ("apply_event error = %d", exec_res));
   if (exec_res == 0)
   {
@@ -3982,14 +4013,16 @@ bool mts_recovery_groups(Relay_log_info
         }
         if (ev->ends_group() || !curr_group_seen_begin)
         {
-            int ret;
+            int ret= 0;
             LOG_POS_COORD ev_coord= { (char *) rli->get_group_master_log_name(),
                                       ev->log_pos };
+            curr_group_seen_begin= FALSE;
+            rli->mts_recovery_group_cnt++;
+
             sql_print_information("Group Recoverying relay log info "
                                   "group_master_log_name %s, event_master_log_pos %lu.",
                                   rli->group_master_log_name,
                                   (ulong) ev->log_pos);
-
             if ((ret= mts_event_coord_cmp(&ev_coord, &w_last)) == 0)
             {
               /* 
@@ -4007,6 +4040,10 @@ bool mts_recovery_groups(Relay_log_info
                     ALFRANIO --> Add more debug messages.
                   */
                   DBUG_PRINT("Mts-checkpoint", ("Bit %u is set.", i));
+                } 
+                else
+                {
+                  DBUG_PRINT("Mts-checkpoint", ("Bit %u is not set.", i));
                 }
               }
 #endif
@@ -4014,11 +4051,12 @@ bool mts_recovery_groups(Relay_log_info
                 ALFRANIO --> Add more debug messages.
               */
               DBUG_PRINT("Mts-checkpoint",
-                         ("Ignoring the first #(%lu) bits. Doing a shift.",
-                         rli->mts_recovery_group_cnt));
+                         ("Doing a shift ini(%lu) end(%lu).",
+                         (w->checkpoint_seqno + 1) - rli->mts_recovery_group_cnt,
+                          w->checkpoint_seqno));
 
-              for (uint i= (w->checkpoint_seqno - rli->mts_recovery_group_cnt) + 1, j= 0;
-                   i <= w->checkpoint_seqno; i++, j++)
+              for (uint i= (w->checkpoint_seqno + 1) - rli->mts_recovery_group_cnt,
+                   j= 0; i <= w->checkpoint_seqno; i++, j++)
               {
                 if (bitmap_is_set(&w->group_execed, i))
                 {
@@ -4029,7 +4067,6 @@ bool mts_recovery_groups(Relay_log_info
                   bitmap_fast_test_and_set(groups, j);
                 }
               }
-              rli->mts_recovery_group_cnt++;
               delete ev;
               ev= NULL;
               break;
@@ -4037,7 +4074,6 @@ bool mts_recovery_groups(Relay_log_info
             else
             {
               DBUG_ASSERT(ret < 0);
-              rli->mts_recovery_group_cnt++;
             }
           }
         delete ev;


Attachment: [text/bzr-bundle] bzr/alfranio.correia@oracle.com-20110622175423-myzbr6j5koflw2k7.bundle
Thread
bzr commit into mysql-next-mr-wl5569 branch (alfranio.correia:3315) Alfranio Correia23 Jun