List:Commits« Previous MessageNext Message »
From:rsomla Date:August 20 2007 7:11pm
Subject:bk commit into 5.1 tree (rafal:1.2531) BUG#21842
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of rafal. When rafal 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@stripped, 2007-08-20 19:11:30+02:00, rafal@quant.(none) +1 -0
  BUG#21842 (Cluster fails to replicate to innodb or myisam with err 134 using TPC-B):
  
  This patch fixes the way write_set is initialized inside Rows_log_events 
  when there are extra columns on slave. Previously the extra columns were
  included in the write_set which is wrong. Now they are not included, as is
  the case in the original source tree.
  
  To correctly handle master/slave record width differences, the m_cols 
  bitmap sent in Rows_log_event should have correct width equal to the 
  number of columns on master. This was not the case because the witdth
  of the bitmap was rounded to nearest multiply of 8. The patch fixes this
  by removing width rounding.

  sql/log_event.cc@stripped, 2007-08-20 19:11:27+02:00, rafal@quant.(none) +25 -36
    - write_set is initialized to contain the same bits as m_bits bitmap sent
      by master (meaning that if slave has extra columns then they are *not*
      included in the write_set),
    
    - moved definition of DBUG_PRINT_BITSET to the beginning of the file
    
    - width of m_cols bitmap in Rows_log_event set to the record width as
      sent by the master (without rounding to closest 8).

diff -Nrup a/sql/log_event.cc b/sql/log_event.cc
--- a/sql/log_event.cc	2007-07-06 16:58:06 +02:00
+++ b/sql/log_event.cc	2007-08-20 19:11:27 +02:00
@@ -36,6 +36,16 @@
 
 #define FLAGSTR(V,F) ((V)&(F)?#F" ":"")
 
+#define DBUG_PRINT_BITSET(N,FRM,BS)                \
+  do {                                             \
+    char buf[256];                                 \
+    for (uint i = 0 ; i < (BS)->n_bits ; ++i)      \
+      buf[i] = bitmap_is_set((BS), i) ? '1' : '0'; \
+    buf[(BS)->n_bits] = '\0';                      \
+    DBUG_PRINT((N), ((FRM), buf));                 \
+  } while (0)
+
+
 /*
   Cache that will automatically be written to a dedicated file on
   destruction.
@@ -5714,11 +5724,11 @@ Rows_log_event::Rows_log_event(const cha
   /* if bitmap_init fails, caught in is_valid() */
   if (likely(!bitmap_init(&m_cols,
                           m_width <= sizeof(m_bitbuf)*8 ? m_bitbuf : NULL,
-                          (m_width + 7) & ~7UL,
+                          m_width,
                           false)))
   {
     DBUG_PRINT("debug", ("Reading from %p", ptr_after_width));
-    memcpy(m_cols.bitmap, ptr_after_width, (m_width + 7) / 8);
+    memcpy(m_cols.bitmap, ptr_after_width, no_bytes_in_map(&m_cols));
     ptr_after_width+= (m_width + 7) / 8;
     DBUG_DUMP("m_cols", (uchar*) m_cols.bitmap, no_bytes_in_map(&m_cols));
   }
@@ -6084,32 +6094,21 @@ int Rows_log_event::do_apply_event(RELAY
       set_flags(COMPLETE_ROWS_F);
 
     /* 
-      Initialize table's write and read sets. Extra columns are included
-      as they will be filled with default values.
-
-      bit pos: 0 1 2 3 4 ... N-1 | N N+1 ... M |
-      bit val: X X X X X .... X  | 1  1  ... 1 |
-
-      N = number of columns on master (m_width)
-      M = number of columns on slave 
-      X = bits from the row's column set (m_cols)      
-
-      We set all bits in read_set since we want to retrieve all columns even
-      when the row is not complete.
-     */
+      Set tables write and read sets.
+      
+      Read_set contains all slave columns (in case we are going to fetch
+      a complete record from slave)
+      
+      Write_set equals the m_cols bitmap sent from master but it can be 
+      longer if slave has extra columns. 
+     */ 
 
-    bitmap_set_all(table->write_set);
+    DBUG_PRINT_BITSET("debug", "Setting table's write_set from: %s", &m_cols);
+    
     bitmap_set_all(table->read_set);
-
-    /* 
-      Note: I (Rafal) couldn't find any bitmap function which would
-      copy bits from m_cols to a prefix of write_set. This is why I use
-      simple loop below.
-     */
-    if (!get_flags(COMPLETE_ROWS_F)) 
-      for (uint bit=0 ; bit < m_width ; ++bit)
-         if (!bitmap_is_set(&m_cols,bit))
-            bitmap_clear_bit(table->write_set,bit);
+    bitmap_set_all(table->write_set);
+    if (!get_flags(COMPLETE_ROWS_F))
+      bitmap_intersect(table->write_set,&m_cols);
 
     // Do event specific preparations 
 
@@ -6932,16 +6931,6 @@ last_uniq_key(TABLE *table, uint keyno)
       return 0;
   return 1;
 }
-
-#define DBUG_PRINT_BITSET(N,FRM,BS)                \
-  do {                                             \
-    char buf[256];                                 \
-    for (uint i = 0 ; i < (BS)->n_bits ; ++i)      \
-      buf[i] = bitmap_is_set((BS), i) ? '1' : '0'; \
-    buf[(BS)->n_bits] = '\0';                      \
-    DBUG_PRINT((N), ((FRM), buf));                 \
-  } while (0)
-
 
 /**
    Check if an error is a duplicate key error.
Thread
bk commit into 5.1 tree (rafal:1.2531) BUG#21842rsomla20 Aug