Commit d0265a63 authored by Michael Widenius's avatar Michael Widenius

When one does 'REPAIR TABLE', update uuid() to the current system


mysql-test/suite/maria/maria-autozerofill.result:
  Updated result
mysql-test/suite/maria/maria-autozerofill.test:
  Added test that zerofilled table should not give any warnings when table is used
mysql-test/suite/maria/maria-recovery2.result:
  More tests to make it easier to find bugs
mysql-test/suite/maria/maria-recovery2.test:
  More tests to make it easier to find bugs
storage/maria/ha_maria.cc:
  Set create_trid after repair (needed if table was moved from another system)
  Set uuid after repair (needed if table was moved from another system)
storage/maria/maria_chk.c:
  Reset share->state.create_trid if we reset share->state.create_rename_lsn.
  Make the table moveable
parent 97463576
...@@ -12,6 +12,8 @@ create table t4 (a int) engine=aria; ...@@ -12,6 +12,8 @@ create table t4 (a int) engine=aria;
INSERT INTO t4 VALUES (1),(2); INSERT INTO t4 VALUES (1),(2);
create table t5 (a int) engine=aria; create table t5 (a int) engine=aria;
INSERT INTO t5 VALUES (1),(2); INSERT INTO t5 VALUES (1),(2);
create table t6 (a int) engine=aria;
INSERT INTO t6 VALUES (1),(2);
flush tables; flush tables;
create_rename_lsn has non-magic value create_rename_lsn has non-magic value
* shut down mysqld, removed logs, restarted it * shut down mysqld, removed logs, restarted it
...@@ -25,6 +27,10 @@ Status: changed,sorted index pages,zerofilled ...@@ -25,6 +27,10 @@ Status: changed,sorted index pages,zerofilled
insert into t1 values(2); insert into t1 values(2);
flush table t1; flush table t1;
create_rename_lsn has non-magic value create_rename_lsn has non-magic value
#
# BUG#44422 "mysql_upgrade destroys Maria tables?"
# Check repair and optimize of moved table
#
check table t2; check table t2;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
mysqltest.t2 check error Table is from another system and must be zerofilled or repaired to be usable on this system mysqltest.t2 check error Table is from another system and must be zerofilled or repaired to be usable on this system
...@@ -59,4 +65,11 @@ mysqltest.t5 repair status OK ...@@ -59,4 +65,11 @@ mysqltest.t5 repair status OK
check table t5; check table t5;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
mysqltest.t5 check status OK mysqltest.t5 check status OK
select * from t6;
a
1
2
check table t6;
Table Op Msg_type Msg_text
mysqltest.t6 check status OK
drop database mysqltest; drop database mysqltest;
...@@ -33,11 +33,13 @@ create table t4 (a int) engine=aria; ...@@ -33,11 +33,13 @@ create table t4 (a int) engine=aria;
INSERT INTO t4 VALUES (1),(2); INSERT INTO t4 VALUES (1),(2);
create table t5 (a int) engine=aria; create table t5 (a int) engine=aria;
INSERT INTO t5 VALUES (1),(2); INSERT INTO t5 VALUES (1),(2);
create table t6 (a int) engine=aria;
INSERT INTO t6 VALUES (1),(2);
flush tables; flush tables;
# Check that table is not zerofilled, not movable # Check that table is not zerofilled, not movable
let $MYSQLD_DATADIR= `select @@datadir`; let $MYSQLD_DATADIR= `select @@datadir`;
--exec $MARIA_CHK -dv $MYSQLD_DATADIR/mysqltest/t1 >$MYSQLTEST_VARDIR/tmp/ariachk.txt --exec $MARIA_CHK -dv --ignore-control-file $MYSQLD_DATADIR/mysqltest/t1 >$MYSQLTEST_VARDIR/tmp/ariachk.txt
perl; perl;
use strict; use strict;
use warnings; use warnings;
...@@ -62,7 +64,7 @@ enable_ps_protocol; ...@@ -62,7 +64,7 @@ enable_ps_protocol;
flush table t1; flush table t1;
# Check that table is auto-zerofilled, movable # Check that table is auto-zerofilled, movable
--exec $MARIA_CHK -dv $MYSQLD_DATADIR/mysqltest/t1 >$MYSQLTEST_VARDIR/tmp/ariachk.txt --exec $MARIA_CHK -dv --ignore-control-file $MYSQLD_DATADIR/mysqltest/t1 >$MYSQLTEST_VARDIR/tmp/ariachk.txt
perl; perl;
use strict; use strict;
use warnings; use warnings;
...@@ -79,7 +81,7 @@ insert into t1 values(2); ...@@ -79,7 +81,7 @@ insert into t1 values(2);
flush table t1; flush table t1;
# Check that table is not zerofilled, not movable # Check that table is not zerofilled, not movable
--exec $MARIA_CHK -dv $MYSQLD_DATADIR/mysqltest/t1 >$MYSQLTEST_VARDIR/tmp/ariachk.txt --exec $MARIA_CHK -dv --ignore-control-file $MYSQLD_DATADIR/mysqltest/t1 >$MYSQLTEST_VARDIR/tmp/ariachk.txt
perl; perl;
use strict; use strict;
use warnings; use warnings;
...@@ -91,10 +93,13 @@ perl; ...@@ -91,10 +93,13 @@ perl;
close FILE; close FILE;
EOF EOF
# --echo #
# BUG#44422 "mysql_upgrade destroys Maria tables?" --echo # BUG#44422 "mysql_upgrade destroys Maria tables?"
# Check repair and optimize of moved table --echo # Check repair and optimize of moved table
# --echo #
# Table t2 is regarded as it would be from another server as we removed
# the aria control file earlier
check table t2; check table t2;
check table t2; check table t2;
repair table t2; repair table t2;
...@@ -108,4 +113,10 @@ check table t5; ...@@ -108,4 +113,10 @@ check table t5;
repair table t5; repair table t5;
check table t5; check table t5;
# Check that if we zerofill with aria_chk, we should not get any warnings when
# accessing the table
--exec $MARIA_CHK --zerofill $MYSQLD_DATADIR/mysqltest/t6 >$MYSQLTEST_VARDIR/tmp/ariachk.txt
select * from t6;
check table t6;
drop database mysqltest; drop database mysqltest;
...@@ -107,6 +107,9 @@ flush table t1; ...@@ -107,6 +107,9 @@ flush table t1;
* copied t1 for comparison * copied t1 for comparison
lock tables t1 write, t2 read; lock tables t1 write, t2 read;
delete from t1 limit 1; delete from t1 limit 1;
select count(*) from t1;
count(*)
0
insert into t1 select * from t2; insert into t1 select * from t2;
SET SESSION debug_dbug="+d,maria_flush_whole_log,maria_flush_whole_page_cache,maria_crash"; SET SESSION debug_dbug="+d,maria_flush_whole_log,maria_flush_whole_page_cache,maria_crash";
* crashing mysqld intentionally * crashing mysqld intentionally
...@@ -123,6 +126,9 @@ use mysqltest; ...@@ -123,6 +126,9 @@ use mysqltest;
show keys from t1; show keys from t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 1 a 1 a A 1 NULL NULL YES BTREE t1 1 a 1 a A 1 NULL NULL YES BTREE
select count(*) from t1;
count(*)
1
drop table t1; drop table t1;
* TEST of recovery when OPTIMIZE has replaced the index file and crash * TEST of recovery when OPTIMIZE has replaced the index file and crash
create table t_corrupted1 (a varchar(100), key(a)) engine=aria; create table t_corrupted1 (a varchar(100), key(a)) engine=aria;
......
...@@ -130,9 +130,11 @@ insert into t1 values(30); ...@@ -130,9 +130,11 @@ insert into t1 values(30);
lock tables t1 write, t2 read; lock tables t1 write, t2 read;
delete from t1 limit 1; delete from t1 limit 1;
# 127 rows in t2, >100, so this will use repair-at-end # 127 rows in t2, >100, so this will use repair-at-end
select count(*) from t1;
insert into t1 select * from t2; insert into t1 select * from t2;
-- source include/maria_verify_recovery.inc -- source include/maria_verify_recovery.inc
show keys from t1; # should be enabled show keys from t1; # should be enabled
select count(*) from t1;
drop table t1; drop table t1;
--echo * TEST of recovery when OPTIMIZE has replaced the index file and crash --echo * TEST of recovery when OPTIMIZE has replaced the index file and crash
......
...@@ -1668,6 +1668,11 @@ int ha_maria::repair(THD *thd, HA_CHECK *param, bool do_optimize) ...@@ -1668,6 +1668,11 @@ int ha_maria::repair(THD *thd, HA_CHECK *param, bool do_optimize)
} }
} }
thd_proc_info(thd, "Saving state"); thd_proc_info(thd, "Saving state");
if (optimize_done && !error && !(param->testflag & T_NO_CREATE_RENAME_LSN))
{
/* Set trid (needed if the table was moved from another system) */
share->state.create_trid= trnman_get_min_safe_trid();
}
mysql_mutex_lock(&share->intern_lock); mysql_mutex_lock(&share->intern_lock);
if (!error) if (!error)
{ {
...@@ -1683,6 +1688,7 @@ int ha_maria::repair(THD *thd, HA_CHECK *param, bool do_optimize) ...@@ -1683,6 +1688,7 @@ int ha_maria::repair(THD *thd, HA_CHECK *param, bool do_optimize)
*/ */
if (file->state != &share->state.state) if (file->state != &share->state.state)
*file->state= share->state.state; *file->state= share->state.state;
if (share->base.auto_key) if (share->base.auto_key)
_ma_update_auto_increment_key(param, file, 1); _ma_update_auto_increment_key(param, file, 1);
if (optimize_done) if (optimize_done)
...@@ -1690,6 +1696,9 @@ int ha_maria::repair(THD *thd, HA_CHECK *param, bool do_optimize) ...@@ -1690,6 +1696,9 @@ int ha_maria::repair(THD *thd, HA_CHECK *param, bool do_optimize)
UPDATE_TIME | UPDATE_OPEN_COUNT | UPDATE_TIME | UPDATE_OPEN_COUNT |
(local_testflag & (local_testflag &
T_STATISTICS ? UPDATE_STAT : 0)); T_STATISTICS ? UPDATE_STAT : 0));
/* File is repaired; Mark the file as moved to this system */
(void) _ma_set_uuid(share, 0);
info(HA_STATUS_NO_LOCK | HA_STATUS_TIME | HA_STATUS_VARIABLE | info(HA_STATUS_NO_LOCK | HA_STATUS_TIME | HA_STATUS_VARIABLE |
HA_STATUS_CONST); HA_STATUS_CONST);
if (rows != file->state->records && !(param->testflag & T_VERY_SILENT)) if (rows != file->state->records && !(param->testflag & T_VERY_SILENT))
......
...@@ -1205,8 +1205,11 @@ static int maria_chk(HA_CHECK *param, char *filename) ...@@ -1205,8 +1205,11 @@ static int maria_chk(HA_CHECK *param, char *filename)
((param->testflag & (T_REP_ANY | T_SORT_RECORDS | T_SORT_INDEX | ((param->testflag & (T_REP_ANY | T_SORT_RECORDS | T_SORT_INDEX |
T_ZEROFILL | T_ZEROFILL_KEEP_LSN)) != T_ZEROFILL | T_ZEROFILL_KEEP_LSN)) !=
(T_ZEROFILL | T_ZEROFILL_KEEP_LSN))) (T_ZEROFILL | T_ZEROFILL_KEEP_LSN)))
{
share->state.create_rename_lsn= share->state.is_of_horizon= share->state.create_rename_lsn= share->state.is_of_horizon=
share->state.skip_redo_lsn= LSN_NEEDS_NEW_STATE_LSNS; share->state.skip_redo_lsn= LSN_NEEDS_NEW_STATE_LSNS;
share->state.create_trid= 0;
}
} }
if (!error && (param->testflag & T_REP_ANY)) if (!error && (param->testflag & T_REP_ANY))
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment