MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Sergey Vojtovich Date:March 12 2010 10:43am
Subject:bzr commit into mysql-5.1-bugteam branch (svoj:3395) Bug#47444
View as plain text  
#At file:///home/svoj/devel/bzr-mysql/mysql-5.1-bugteam-bug47444/ based on revid:joro@stripped

 3395 Sergey Vojtovich	2010-03-12
      BUG#47444 - --myisam_repair_threads>1can result in all
                  index cardinalities=1
      
      Parallel repair didn't poroperly update index cardinality
      in certain cases.
      
      When myisam_sort_buffer_size is not enough to store all
      keys, index cardinality was updated before index was
      actually written, when no index statistic is available.
     @ mysql-test/r/myisam.result
        A test case for BUG#47444.
     @ mysql-test/t/myisam.test
        A test case for BUG#47444.
     @ storage/myisam/sort.c
        update_key_parts() must be called after all index
        entries are written, when index statistic is available.

    modified:
      mysql-test/r/myisam.result
      mysql-test/t/myisam.test
      storage/myisam/sort.c
=== modified file 'mysql-test/r/myisam.result'
--- a/mysql-test/r/myisam.result	2010-03-10 12:32:12 +0000
+++ b/mysql-test/r/myisam.result	2010-03-12 10:43:30 +0000
@@ -2389,4 +2389,23 @@ SELECT * FROM t1, t1 AS a1 WHERE t1.a=1 
 a	a
 1	1
 DROP TABLE t1;
+#
+# BUG#47444 - --myisam_repair_threads>1can result in all index
+#             cardinalities=1
+#
+SET myisam_repair_threads=2;
+SET myisam_sort_buffer_size=4096;
+CREATE TABLE t1(a CHAR(255), KEY(a), KEY(a), KEY(a));
+INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9),(0),(1),(2),(3);
+REPAIR TABLE t1;
+Table	Op	Msg_type	Msg_text
+test.t1	repair	status	OK
+SELECT CARDINALITY FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1';
+CARDINALITY
+14
+14
+14
+DROP TABLE t1;
+SET myisam_sort_buffer_size=@@global.myisam_sort_buffer_size;
+SET myisam_repair_threads=@@global.myisam_repair_threads;
 End of 5.1 tests

=== modified file 'mysql-test/t/myisam.test'
--- a/mysql-test/t/myisam.test	2010-03-10 12:32:12 +0000
+++ b/mysql-test/t/myisam.test	2010-03-12 10:43:30 +0000
@@ -1631,4 +1631,18 @@ INSERT INTO t1 VALUES('1');
 SELECT * FROM t1, t1 AS a1 WHERE t1.a=1 AND a1.a=1;
 DROP TABLE t1;
 
+--echo #
+--echo # BUG#47444 - --myisam_repair_threads>1can result in all index
+--echo #             cardinalities=1
+--echo #
+SET myisam_repair_threads=2;
+SET myisam_sort_buffer_size=4096;
+CREATE TABLE t1(a CHAR(255), KEY(a), KEY(a), KEY(a));
+INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9),(0),(1),(2),(3);
+REPAIR TABLE t1;
+SELECT CARDINALITY FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1';
+DROP TABLE t1;
+SET myisam_sort_buffer_size=@@global.myisam_sort_buffer_size;
+SET myisam_repair_threads=@@global.myisam_repair_threads;
+
 --echo End of 5.1 tests

=== modified file 'storage/myisam/sort.c'
--- a/storage/myisam/sort.c	2009-10-27 14:27:27 +0000
+++ b/storage/myisam/sort.c	2010-03-12 10:43:30 +0000
@@ -506,7 +506,7 @@ int thr_write_keys(MI_SORT_PARAM *sort_p
 
   for (i= 0, sinfo= sort_param ;
        i < sort_info->total_keys ;
-       i++, rec_per_key_part+=sinfo->keyinfo->keysegs, sinfo++)
+       i++, sinfo++)
   {
     if (!sinfo->sort_keys)
     {
@@ -529,11 +529,6 @@ int thr_write_keys(MI_SORT_PARAM *sort_p
             flush_ft_buf(sinfo) || flush_pending_blocks(sinfo))
           got_error=1;
       }
-      if (!got_error && param->testflag & T_STATISTICS)
-        update_key_parts(sinfo->keyinfo, rec_per_key_part, sinfo->unique,
-                         param->stats_method == MI_STATS_METHOD_IGNORE_NULLS?
-                         sinfo->notnull: NULL,
-                         (ulonglong) info->state->records);
     }
     my_free((uchar*) sinfo->sort_keys,MYF(0));
     my_free(mi_get_rec_buff_ptr(info, sinfo->rec_buff),
@@ -547,7 +542,7 @@ int thr_write_keys(MI_SORT_PARAM *sort_p
 	 delete_dynamic(&sinfo->buffpek),
 	 close_cached_file(&sinfo->tempfile),
 	 close_cached_file(&sinfo->tempfile_for_exceptions),
-	 sinfo++)
+         rec_per_key_part+= sinfo->keyinfo->keysegs, sinfo++)
   {
     if (got_error)
       continue;
@@ -639,6 +634,11 @@ int thr_write_keys(MI_SORT_PARAM *sort_p
           got_error=1;
       }
     }
+    if (!got_error && param->testflag & T_STATISTICS)
+      update_key_parts(sinfo->keyinfo, rec_per_key_part, sinfo->unique,
+                       param->stats_method == MI_STATS_METHOD_IGNORE_NULLS ?
+                       sinfo->notnull : NULL,
+                       (ulonglong) info->state->records);
   }
   my_free((uchar*) mergebuf,MYF(MY_ALLOW_ZERO_PTR));
   DBUG_RETURN(got_error);


Attachment: [text/bzr-bundle] bzr/svoj@sun.com-20100312104330-s2ov8zmmq2p5rftp.bundle
Thread
bzr commit into mysql-5.1-bugteam branch (svoj:3395) Bug#47444Sergey Vojtovich12 Mar