Bug #42379 Maria: when copying a table from another instance, CHECK TABLE says it's corrupt
Submitted: 27 Jan 2009 16:44 Modified: 26 May 2010 17:51
Reporter: Guilhem Bichot Email Updates:
Status: Unsupported Impact on me:
None 
Category:MySQL Server: Maria storage engine Severity:S3 (Non-critical)
Version:5.1-maria OS:Any
Assigned to: CPU Architecture:Any
Triage: Triaged: D2 (Serious)

[27 Jan 2009 16:44] Guilhem Bichot
Description:
If CHECK TABLE is the first command run on a table after this table is copied from another Maria instance (having a different uuid) it reports an error; this is because it does not zerofill it first (unlike some other statements).
This affects not only manual copies like this, but also, when MyISAM's online backup driver is ported to Maria (which is in progress):
BACKUP on one instance;
RESTORE on another instance;
CHECK TABLE to check your restored tables - corrupted!

How to repeat:
./mtr --mem --start-and-exit alias
create table t(a int) engine=maria;
insert into t values(1)
insert into t values(2);
killall mysqld
cp var/master-data/t.* /tmp
./mtr --mem --start-and-exit alias
cp /tmp/t.* var/master-data
# start your mysql client with -A !!
check table t;
+--------+-------+----------+----------------------------------------------------------------------------------------------+
| Table  | Op    | Msg_type | Msg_text                                                                                     |
+--------+-------+----------+----------------------------------------------------------------------------------------------+
| test.t | check | error    | Found row with transaction id 2 when max transaction id according to maria_control_file is 1 |
| test.t | check | error    | Corrupt                                                                                      |
+--------+-------+----------+----------------------------------------------------------------------------------------------+
[27 Jan 2009 17:59] Guilhem Bichot
and if instead of CHECK I do "SELECT * from t" I get a warning which is misleading because table does NOT  need a repair:
mysql> show warnings;
--------------
show warnings
--------------

+-------+------+--------------------------------------------------------+
| Level | Code | Message                                                |
+-------+------+--------------------------------------------------------+
| Error | 1194 | Table 't' is marked as crashed and should be repaired |
+-------+------+--------------------------------------------------------+
1 row in set (0.01 sec)
[27 Jan 2009 18:00] Guilhem Bichot
in my 'cp' commands, add "/test" after var/master-data.
[27 Jan 2009 20:43] Guilhem Bichot
The warning for SELECT can be seen in mysql-test/suite/maria/r/maria-autozerofill.result.
The error for CHECK can be seen too by applying this patch:
=== modified file 'mysql-test/suite/maria/t/maria-autozerofill.test'
--- mysql-test/suite/maria/t/maria-autozerofill.test    2008-10-01 12:13:39 +0000
+++ mysql-test/suite/maria/t/maria-autozerofill.test    2009-01-27 20:42:19 +0000
@@ -22,6 +22,7 @@

 create table t1(a int) engine=maria;
 insert into t1 values(1);
+insert into t1 values(2);
 flush table t1;
 # Check that table is not zerofilled, not movable
 --exec $MARIA_CHK -dv $MYSQLTEST_VARDIR/master-data/mysqltest/t1 >$MYSQLTEST_VARDIR/tmp/mariachk.txt
@@ -43,7 +44,7 @@

 disable_ps_protocol; # see maria-recover.test
 replace_regex /Table.*t1/t1/ ;
-select * from t1;
+check table t1;
 enable_ps_protocol;
 flush table t1;