List:Commits« Previous MessageNext Message »
From:Luis Soares Date:May 21 2010 10:48pm
Subject:bzr commit into mysql-5.1-rpl-wl5092 branch (luis.soares:3187)
Bug#53889
View as plain text  
#At file:///home/lsoares/Workspace/bzr/work/bugfixing/53889/mysql-5.1-rpl-wl5092/ based on revid:luis.soares@stripped

 3187 Luis Soares	2010-05-21
      BUG#53889: slaves stops with 1032; handler error HA_ERR_KEY_NOT_FOUND
      
      At the slave, while searching for the correct row to update, the
      index init function (ha_index_init) was initializing always the
      0th index, even if some other nth index was set to be used.
      
      We fix this by setting the correct parameter (key) when calling
      the index initialization function.
      
      Apart from fixing the bug, we also improve the index lookup
      routine to distinguish unique indexes that have null parts from
      those that don't.
     @ mysql-test/suite/rpl/t/rpl_row_disabled_slave_key.test
        Added test case.

    modified:
      mysql-test/suite/rpl/r/rpl_row_disabled_slave_key.result
      mysql-test/suite/rpl/t/rpl_row_disabled_slave_key.test
      sql/log_event.cc
=== modified file 'mysql-test/suite/rpl/r/rpl_row_disabled_slave_key.result'
--- a/mysql-test/suite/rpl/r/rpl_row_disabled_slave_key.result	2009-09-27 21:02:47 +0000
+++ b/mysql-test/suite/rpl/r/rpl_row_disabled_slave_key.result	2010-05-21 22:47:59 +0000
@@ -24,3 +24,19 @@ INSERT INTO t VALUES (1,2,4);
 INSERT INTO t VALUES (4,3,4);
 DELETE FROM t;
 DROP TABLE t;
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+CREATE TABLE t2 (col4 CHAR(25) DEFAULT NULL,
+col1 BIGINT,
+col2 TINYINT NOT NULL,
+col5 VARCHAR(25) DEFAULT ''
+                ) ENGINE = myisam;
+ALTER TABLE t2 ADD INDEX idx1 ( col4 ) , ADD UNIQUE INDEX idx2 ( col5 );
+INSERT INTO t2 ( col4 , col2 ) VALUES ( 'Hello', -77 ) ;
+UPDATE t2 SET col1 = 13 WHERE col2 = -77;
+Comparing tables master:test.t2 and slave:test.t2
+DROP TABLE t2;

=== modified file 'mysql-test/suite/rpl/t/rpl_row_disabled_slave_key.test'
--- a/mysql-test/suite/rpl/t/rpl_row_disabled_slave_key.test	2009-09-27 21:02:47 +0000
+++ b/mysql-test/suite/rpl/t/rpl_row_disabled_slave_key.test	2010-05-21 22:47:59 +0000
@@ -71,3 +71,30 @@ DELETE FROM t;
 DROP TABLE t;
 
 -- sync_slave_with_master
+
+#
+# BUG#53889: slaves stops with 1032; handler error HA_ERR_KEY_NOT_FOUND
+#
+-- connection master
+-- source include/master-slave-reset.inc
+-- connection master
+
+CREATE TABLE t2 (col4 CHAR(25) DEFAULT NULL,
+                 col1 BIGINT,
+                 col2 TINYINT NOT NULL,
+                 col5 VARCHAR(25) DEFAULT ''
+                ) ENGINE = myisam;
+
+ALTER TABLE t2 ADD INDEX idx1 ( col4 ) , ADD UNIQUE INDEX idx2 ( col5 );
+INSERT INTO t2 ( col4 , col2 ) VALUES ( 'Hello', -77 ) ;
+UPDATE t2 SET col1 = 13 WHERE col2 = -77;
+
+-- sync_slave_with_master
+
+-- let $diff_table_1=master:test.t2
+-- let $diff_table_2=slave:test.t2
+-- source include/diff_tables.inc
+
+-- connection master
+DROP TABLE t2;
+--sync_slave_with_master

=== modified file 'sql/log_event.cc'
--- a/sql/log_event.cc	2010-03-04 17:00:32 +0000
+++ b/sql/log_event.cc	2010-05-21 22:47:59 +0000
@@ -9102,7 +9102,8 @@ my_bool are_all_columns_signaled_for_key
       Returns a unique key (flagged with HA_NOSAME)
 
     - MULTIPLE_KEY_FLAG
-      Returns a key not unique nor PK.
+      Returns a key that is not unique (flagged with HA_NOSAME 
+      and without HA_NULL_PART_KEY) nor PK.
 
   The above flags can be used together, in which case, the
   search is conducted in the above listed order. Eg, the 
@@ -9146,8 +9147,13 @@ search_key_in_table(TABLE *table, MY_BIT
          (key < table->s->keys) && (res == MAX_KEY);
          key++,keyinfo++)
     {
-      if (!(keyinfo->flags & HA_NOSAME) || /* skip not unique */
-          (key == table->s->primary_key))  /* skip primary */
+      /*
+        - Unique keys cannot be disabled, thence we skip the check.
+        - Skip unique keys with nullable parts
+        - Skip primary keys
+      */
+      if (!((keyinfo->flags & (HA_NOSAME | HA_NULL_PART_KEY)) != HA_NOSAME) ||
+          (key == table->s->primary_key))
         continue;
       res= are_all_columns_signaled_for_key(keyinfo, bi_cols) ? 
            key : MAX_KEY;
@@ -9163,9 +9169,14 @@ search_key_in_table(TABLE *table, MY_BIT
          (key < table->s->keys) && (res == MAX_KEY);
          key++,keyinfo++)
     {
-      if (!(table->s->keys_in_use.is_set(key)) || /* key is no active */
-          (keyinfo->flags & HA_NOSAME) || /* skip uniques */
-          (key == table->s->primary_key)) /* skip primary */
+      /*
+        - Skip innactive keys
+        - Skip unique keys without nullable parts
+        - Skip primary keys
+      */
+      if (!(table->s->keys_in_use.is_set(key)) ||
+          ((keyinfo->flags & (HA_NOSAME | HA_NULL_PART_KEY)) == HA_NOSAME) ||
+          (key == table->s->primary_key))
         continue;
 
       res= are_all_columns_signaled_for_key(keyinfo, bi_cols) ? 
@@ -9301,8 +9312,8 @@ INDEX_SCAN:
 
     DBUG_PRINT("info",("locating record using primary key (index_read)"));
 
-    /* The 0th key is active: search the table using the index */
-    if (!table->file->inited && (error= table->file->ha_index_init(0, FALSE)))
+    /* The key'th key is active and usable: search the table using the index */
+    if (!table->file->inited && (error= table->file->ha_index_init(key, FALSE)))
     {
       DBUG_PRINT("info",("ha_index_init returns error %d",error));
       table->file->print_error(error, MYF(0));


Attachment: [text/bzr-bundle] bzr/luis.soares@sun.com-20100521224759-1i0z33qiyczwpbul.bundle
Thread
bzr commit into mysql-5.1-rpl-wl5092 branch (luis.soares:3187)Bug#53889Luis Soares22 May