#At file:///Users/mattiasj/clones/bzrroot/b35161-51-bugteam/
2661 Mattias Jonsson 2008-06-09
Bug#35161: --myisam-recover does not work for partitioned MyISAM tables
Problem was that auto_repair, is_crashed and check_and_repair was not
implemented in ha_partition.
Solution, implemented them as loop over all partitions for is_crashed and
check_and_repair, and using the first partition for auto_repair.
added:
mysql-test/std_data/corrupt_t1#P#p1.MYI
mysql-test/std_data/corrupt_t1.MYI
mysql-test/suite/parts/r/partition_repair_myisam.result
mysql-test/suite/parts/t/partition_repair_myisam-master.opt
mysql-test/suite/parts/t/partition_repair_myisam.test
modified:
mysql-test/lib/mtr_report.pl
sql/ha_partition.cc
sql/ha_partition.h
per-file messages:
mysql-test/lib/mtr_report.pl
Bug#35161: --myisam-recover does not work for partitioned MyISAM tables
Added filter for crashed tables, when testing auto repair
mysql-test/std_data/corrupt_t1#P#p1.MYI
Bug#35161: --myisam-recover does not work for partitioned MyISAM tables
Corrupt MYI file for testing auto repair.
mysql-test/std_data/corrupt_t1.MYI
Bug#35161: --myisam-recover does not work for partitioned MyISAM tables
Corrupt MYI file for testing auto repair
mysql-test/suite/parts/r/partition_repair_myisam.result
Bug#35161: --myisam-recover does not work for partitioned MyISAM tables
Test result file
mysql-test/suite/parts/t/partition_repair_myisam-master.opt
Bug#35161: --myisam-recover does not work for partitioned MyISAM tables
opt file for testing of --myisam-recover
mysql-test/suite/parts/t/partition_repair_myisam.test
Bug#35161: --myisam-recover does not work for partitioned MyISAM tables
Test file for testing auto repair of crashed myisam partitions
sql/ha_partition.cc
Bug#35161: --myisam-recover does not work for partitioned MyISAM tables
Added auto_repair as returning the first partitions auto_repair
Added is_crashed and check_and_repair as loop over all partitions
sql/ha_partition.h
Bug#35161: --myisam-recover does not work for partitioned MyISAM tables
Activating check_and_repair, auto_repair and is_crashed
=== modified file 'mysql-test/lib/mtr_report.pl'
--- a/mysql-test/lib/mtr_report.pl 2008-03-28 10:14:27 +0000
+++ b/mysql-test/lib/mtr_report.pl 2008-06-09 12:18:03 +0000
@@ -402,7 +402,10 @@ sub mtr_report_stats ($) {
)) or
# Test case for Bug#31590 produces the following error:
- /Out of sort memory; increase server sort buffer size/
+ /Out of sort memory; increase server sort buffer size/ or
+
+ # Bug#35161, test of auto repair --myisam-recover
+ /able.*_will_crash/
)
{
next; # Skip these lines
=== added file 'mysql-test/std_data/corrupt_t1#P#p1.MYI'
Binary files a/mysql-test/std_data/corrupt_t1#P#p1.MYI 1970-01-01 00:00:00 +0000 and
b/mysql-test/std_data/corrupt_t1#P#p1.MYI 2008-06-09 12:18:03 +0000 differ
=== added file 'mysql-test/std_data/corrupt_t1.MYI'
Binary files a/mysql-test/std_data/corrupt_t1.MYI 1970-01-01 00:00:00 +0000 and
b/mysql-test/std_data/corrupt_t1.MYI 2008-06-09 12:18:03 +0000 differ
=== added file 'mysql-test/suite/parts/r/partition_repair_myisam.result'
--- a/mysql-test/suite/parts/r/partition_repair_myisam.result 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/r/partition_repair_myisam.result 2008-06-09 12:18:03 +0000
@@ -0,0 +1,56 @@
+CREATE TABLE t1_will_crash (a INT, KEY (a)) ENGINE=MyISAM;
+INSERT INTO t1_will_crash VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10), (11);
+FLUSH TABLES;
+# replacing t1.MYI with a corrupt + unclosed one created by doing:
+# 'create table t1 (a int key(a))' head -c1024 t1.MYI > corrupt_t1.MYI
+SELECT * FROM t1_will_crash;
+a
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+Warnings:
+Error 145 Table './test/t1_will_crash' is marked as crashed and should be repaired
+Error 1194 Table 't1_will_crash' is marked as crashed and should be repaired
+Error 1034 1 client is using or hasn't closed the table properly
+Error 1034 Size of indexfile is: 1024 Should be: 2048
+Error 1034 Size of datafile is: 77 Should be: 7
+Error 1034 Number of rows changed from 1 to 11
+DROP TABLE t1_will_crash;
+CREATE TABLE t1_will_crash (a INT, KEY (a))
+ENGINE=MyISAM
+PARTITION BY HASH(a)
+PARTITIONS 3;
+INSERT INTO t1_will_crash VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10), (11);
+FLUSH TABLES;
+# replacing t1#P#p1.MYI with a corrupt + unclosed one created by doing:
+# 'create table t1 (a int key(a)) partition by hash (a) partitions 3'
+# head -c1024 t1#P#p1.MYI > corrupt_t1#P#p1.MYI
+SELECT * FROM t1_will_crash;
+a
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+Warnings:
+Error 145 Table './test/t1_will_crash#P#p1' is marked as crashed and should be repaired
+Error 1194 Table 't1_will_crash' is marked as crashed and should be repaired
+Error 1034 1 client is using or hasn't closed the table properly
+Error 1034 Size of indexfile is: 1024 Should be: 2048
+Error 1034 Size of datafile is: 28 Should be: 7
+Error 1034 Number of rows changed from 1 to 4
+DROP TABLE t1_will_crash;
=== added file 'mysql-test/suite/parts/t/partition_repair_myisam-master.opt'
--- a/mysql-test/suite/parts/t/partition_repair_myisam-master.opt 1970-01-01 00:00:00
+0000
+++ b/mysql-test/suite/parts/t/partition_repair_myisam-master.opt 2008-06-09 12:18:03
+0000
@@ -0,0 +1 @@
+--myisam-recover
=== added file 'mysql-test/suite/parts/t/partition_repair_myisam.test'
--- a/mysql-test/suite/parts/t/partition_repair_myisam.test 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/parts/t/partition_repair_myisam.test 2008-06-09 12:18:03 +0000
@@ -0,0 +1,30 @@
+--source include/have_partition.inc
+--disable_warnings
+--disable_query_log
+drop table if exists t1_will_crash;
+--enable_query_log
+--enable_warnings
+
+
+CREATE TABLE t1_will_crash (a INT, KEY (a)) ENGINE=MyISAM;
+INSERT INTO t1_will_crash VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10), (11);
+FLUSH TABLES;
+--echo # replacing t1.MYI with a corrupt + unclosed one created by doing:
+--echo # 'create table t1 (a int key(a))' head -c1024 t1.MYI > corrupt_t1.MYI
+--remove_file $MYSQLTEST_VARDIR/master-data/test/t1_will_crash.MYI
+--copy_file std_data/corrupt_t1.MYI $MYSQLTEST_VARDIR/master-data/test/t1_will_crash.MYI
+SELECT * FROM t1_will_crash;
+DROP TABLE t1_will_crash;
+CREATE TABLE t1_will_crash (a INT, KEY (a))
+ENGINE=MyISAM
+PARTITION BY HASH(a)
+PARTITIONS 3;
+INSERT INTO t1_will_crash VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10), (11);
+FLUSH TABLES;
+--echo # replacing t1#P#p1.MYI with a corrupt + unclosed one created by doing:
+--echo # 'create table t1 (a int key(a)) partition by hash (a) partitions 3'
+--echo # head -c1024 t1#P#p1.MYI > corrupt_t1#P#p1.MYI
+--remove_file $MYSQLTEST_VARDIR/master-data/test/t1_will_crash#P#p1.MYI
+--copy_file std_data/corrupt_t1#P#p1.MYI
$MYSQLTEST_VARDIR/master-data/test/t1_will_crash#P#p1.MYI
+SELECT * FROM t1_will_crash;
+DROP TABLE t1_will_crash;
=== modified file 'sql/ha_partition.cc'
--- a/sql/ha_partition.cc 2008-03-28 10:14:27 +0000
+++ b/sql/ha_partition.cc 2008-06-09 12:18:03 +0000
@@ -1129,6 +1129,93 @@ int ha_partition::handle_opt_partitions(
#endif
}
+
+/*
+ Check and repair the table if neccesary
+
+ SYNOPSIS
+ check_and_repair()
+ thd Thread object
+
+ RETURN VALUE
+ TRUE Error/Not supported
+ FALSE Success
+
+*/
+
+bool ha_partition::check_and_repair(THD *thd)
+{
+ int error= FALSE;
+ handler **file;
+ DBUG_ENTER("ha_partition::check_and_repair");
+
+ file= m_file;
+ do
+ {
+ if ((error= (*file)->ha_check_and_repair(thd)))
+ break;
+ } while (*(++file));
+ DBUG_RETURN(error);
+}
+
+
+/*
+ Check if the table can be automatically repaired
+
+ SYNOPSIS
+ auto_repair()
+
+ RETURN VALUE
+ TRUE Can be auto repaired
+ FALSE Cannot be auto repaired
+
+*/
+
+bool ha_partition::auto_repair() const
+{
+ handler **file;
+ DBUG_ENTER("ha_partition::auto_repair");
+
+ /*
+ As long as we only support one storage engine per table,
+ we can use the first partition for this function.
+ */
+ file= m_file;
+ DBUG_RETURN((*file)->auto_repair());
+}
+
+
+
+/*
+ Check if the table is crashed
+
+ SYNOPSIS
+ is_crashed()
+
+ RETURN VALUE
+ TRUE Crashed
+ FALSE Not crashed
+
+ DESCRIPTION
+ Checks if any partition in the table is crashed.
+*/
+
+bool ha_partition::is_crashed() const
+{
+ int error= FALSE;
+ handler **file;
+ DBUG_ENTER("ha_partition::is_crashed");
+
+ file= m_file;
+ do
+ {
+ if ((error= (*file)->is_crashed()))
+ break;
+ } while (*(++file));
+ DBUG_RETURN(error);
+}
+
+
/*
Prepare by creating a new partition
=== modified file 'sql/ha_partition.h'
--- a/sql/ha_partition.h 2007-10-11 15:07:40 +0000
+++ b/sql/ha_partition.h 2008-06-09 12:18:03 +0000
@@ -935,6 +935,9 @@ public:
virtual int analyze_partitions(THD *thd);
virtual int check_partitions(THD *thd);
virtual int repair_partitions(THD *thd);
+ virtual bool check_and_repair(THD *thd);
+ virtual bool auto_repair() const;
+ virtual bool is_crashed() const;
private:
int handle_opt_partitions(THD *thd, HA_CHECK_OPT *check_opt,
@@ -950,12 +953,9 @@ public:
virtual int restore(THD* thd, HA_CHECK_OPT *check_opt);
virtual int assign_to_keycache(THD* thd, HA_CHECK_OPT *check_opt);
virtual int preload_keys(THD *thd, HA_CHECK_OPT *check_opt);
- virtual bool check_and_repair(THD *thd);
virtual int dump(THD* thd, int fd = -1);
virtual int net_read_dump(NET* net);
virtual uint checksum() const;
- virtual bool is_crashed() const;
- virtual bool auto_repair() const;
*/
/*
| Thread |
|---|
| • bzr commit into mysql-5.1 branch (mattiasj:2661) Bug#35161 | Mattias Jonsson | 9 Jun |