#At file:///export/home/log/Narayanan/mysql_checkouts_bazaar/5.1_main_repository/mysql-5.0-bugteam-41709/ based on revid:joro@stripped
2729 Narayanan V 2009-04-20
Bug#41709 myisam external locking doesn't work as advertised
When an extended repair is run on a table, the datafile of
the table is re-written, but the server does not refresh its
datafile pointer. This causes check to report corruptions,
because there is a mis-match between the datafile sizes
recorded in the index file and the size of the actual datafile.
This patch fixes the problem by refreshing the datafile pointer
everytime a rewrite of the datafile associated with the table is
detected.
@ myisam/mi_locking.c
close and open the datafile pointer everytime
the datafile is re-written.
@ mysql-test/r/myisam.result
Contains the result file for the tests.
@ mysql-test/t/myisam.test
Run insert and myisamchk on the table being
inserted into to ensure that the server is
pointing to the correct datafile pointer, after
myisamchk rewrites it.
modified:
myisam/mi_locking.c
mysql-test/r/myisam.result
mysql-test/t/myisam.test
=== modified file 'myisam/mi_locking.c'
--- a/myisam/mi_locking.c 2007-01-03 07:52:50 +0000
+++ b/myisam/mi_locking.c 2009-04-20 13:14:22 +0000
@@ -478,6 +478,18 @@ int _mi_test_if_changed(register MI_INFO
info->last_loop= share->state.update_count;
info->update|= HA_STATE_WRITTEN; /* Must use file on next */
info->data_changed= 1; /* For mi_is_changed */
+ /*
+ check if the datafile has been renamed, can happen for example by
+ running server and mysaimchk parallely, synchonized using external
+ locks. In this cases the handle to the datafile needs to be
+ and reopened to enable getting a handle to the newly created
+ datafile.
+ */
+ if(share->state.version != share->last_version)
+ {
+ my_close(info->dfile,MYF(0));
+ mi_open_datafile(info,share,share->data_file_name,-1);
+ }
return 1;
}
return (!(info->update & HA_STATE_AKTIV) ||
=== modified file 'mysql-test/r/myisam.result'
--- a/mysql-test/r/myisam.result 2008-08-26 13:48:50 +0000
+++ b/mysql-test/r/myisam.result 2009-04-20 13:14:22 +0000
@@ -1883,4 +1883,70 @@ CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
DROP TABLE t1;
+#
+# Bug #41709 - myisam external locking doesn't work as advertised
+
+Create table 't1' that will be used during the test run
+
+CREATE TABLE `t1`(
+`id` INT,
+`name` VARCHAR(255),
+KEY (`id`,`name`),
+KEY (`name`,`id`),
+KEY (`name`),
+KEY (`id`)) ENGINE=MyISAM;
+
+Insert first value
+
+INSERT INTO `t1` VALUES (1, 'FIRST ENTRY');
+
+Run myisamchk
+
+
+MyISAM file: /export/home/log/Narayanan/mysql_checkouts_bazaar/5.1_main_repository/mysql-5.0-bugteam-41709/mysql-test/var/master-data//test/t1
+Record format: Packed
+Character set: latin1_swedish_ci (8)
+Data records: 1 Deleted blocks: 0
+Recordlength: 262
+
+table description:
+Key Start Len Index Type
+1 2 4 multip. long prefix NULL
+ 6 255 varchar NULL
+2 6 255 multip. varchar prefix NULL
+ 2 4 long NULL
+3 6 255 multip. varchar prefix NULL
+4 2 4 multip. long NULL
+
+Insert second value
+
+INSERT INTO `t1` VALUES (2, 'SECOND ENTRY');
+
+run myisamchk
+
+
+MyISAM file: /export/home/log/Narayanan/mysql_checkouts_bazaar/5.1_main_repository/mysql-5.0-bugteam-41709/mysql-test/var/master-data//test/t1
+Record format: Packed
+Character set: latin1_swedish_ci (8)
+Data records: 2 Deleted blocks: 0
+Recordlength: 262
+
+table description:
+Key Start Len Index Type
+1 2 4 multip. long prefix NULL
+ 6 255 varchar NULL
+2 6 255 multip. varchar prefix NULL
+ 2 4 long NULL
+3 6 255 multip. varchar prefix NULL
+4 2 4 multip. long NULL
+
+run the check on the table
+
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+
+drop table t1 used during test run
+
+DROP TABLE t1;
End of 5.0 tests
=== modified file 'mysql-test/t/myisam.test'
--- a/mysql-test/t/myisam.test 2008-08-26 13:48:50 +0000
+++ b/mysql-test/t/myisam.test 2009-04-20 13:14:22 +0000
@@ -1225,4 +1225,42 @@ SELECT a FROM t1;
CHECK TABLE t1;
DROP TABLE t1;
+--echo #
+--echo # Bug #41709 - myisam external locking doesn't work as advertised
+--echo
+--echo Create table 't1' that will be used during the test run
+--echo
+CREATE TABLE `t1`(
+`id` INT,
+`name` VARCHAR(255),
+KEY (`id`,`name`),
+KEY (`name`,`id`),
+KEY (`name`),
+KEY (`id`)) ENGINE=MyISAM;
+let $MYSQLD_DATADIR= `select @@datadir`;
+--echo
+--echo Insert first value
+--echo
+INSERT INTO `t1` VALUES (1, 'FIRST ENTRY');
+--echo
+--echo Run myisamchk
+--echo
+--exec $MYISAMCHK -d $MYSQLD_DATADIR/test/t1
+--echo
+--echo Insert second value
+--echo
+INSERT INTO `t1` VALUES (2, 'SECOND ENTRY');
+--echo
+--echo run myisamchk
+--echo
+--exec $MYISAMCHK -d $MYSQLD_DATADIR/test/t1
+--echo
+--echo run the check on the table
+--echo
+CHECK TABLE t1;
+--echo
+--echo drop table t1 used during test run
+--echo
+DROP TABLE t1;
+
--echo End of 5.0 tests
Attachment: [text/bzr-bundle] bzr/v.narayanan@sun.com-20090420131422-dzv9ih7ptnkpc4gs.bundle
Thread |
---|
• bzr commit into mysql-5.0-bugteam branch (v.narayanan:2729) Bug#41709 | Narayanan V | 20 Apr |