mirror of
https://github.com/MariaDB/server.git
synced 2025-01-18 04:53:01 +01:00
7323df7885
Test for BUG#34106 "auto_increment is reset to 1 when table is recovered from crash" (fixed by Monty yesterday) mysql-test/r/maria-recovery.result: result, which is correct (before pulling Monty's fix for BUG#34106, we got a warning about auto_increment in CHECK TABLE (done in maria-verify-recovery.inc), no AUTO_INCREMENT clause in SHOW CREATE TABLE, and a failure of the last INSERT. mysql-test/r/maria.result: result mysql-test/t/maria-recovery.test: Test for BUG#34106 mysql-test/t/maria.test: look at what is reported in SHOW ENGINES mysys/my_pread.c: changed my mind: if Count argument is >4GB, we'll surely see a segfault in the pread() call when it tries to read 4GB from memory, so no need to print it in ulonglong format (saves a function call). mysys/my_read.c: changed my mind: if Count argument is >4GB, we'll surely see a segfault in the pread() call when it tries to read 4GB from memory, so no need to print it in ulonglong format (saves a function call). mysys/my_write.c: changed my mind: if Count argument is >4GB, we'll surely see a segfault in the pread() call when it tries to read 4GB from memory, so no need to print it in ulonglong format (saves a function call). storage/maria/ha_maria.cc: Description representing the current reality. This can be changed later storage/maria/ma_page.c: When reading the new key_del from a page on disk, if there is a bug (like BUG#34062) this key_del could be wrong, we try to catch if it's out of the key file. storage/maria/ma_pagecache.c: - no truncation of page's number in DBUG_PRINT (useful for BUG#34062) - page_korr instead of uint5korr storage/maria/ma_recovery.c: page_korr instead of uint5korr storage/maria/plug.in: Description representing the current reality. This can be changed later.
385 lines
11 KiB
Text
385 lines
11 KiB
Text
set global maria_log_file_size=4294967295;
|
|
drop database if exists mysqltest;
|
|
create database mysqltest;
|
|
use mysqltest;
|
|
* shut down mysqld, removed logs, restarted it
|
|
use mysqltest;
|
|
create table t1 (a varchar(1000)) engine=maria;
|
|
* TEST of REDO: see if recovery can reconstruct if we give it an old table
|
|
* copied t1 for feeding_recovery
|
|
insert into t1 values ("00000000");
|
|
flush table t1;
|
|
* copied t1 for comparison
|
|
SET SESSION debug="+d,maria_flush_whole_log,maria_crash";
|
|
* crashing mysqld intentionally
|
|
set global maria_checkpoint_interval=1;
|
|
ERROR HY000: Lost connection to MySQL server during query
|
|
* copied t1 back for feeding_recovery
|
|
* recovery happens
|
|
check table t1 extended;
|
|
Table Op Msg_type Msg_text
|
|
mysqltest.t1 check status OK
|
|
* testing that checksum after recovery is as expected
|
|
Checksum-check
|
|
ok
|
|
* compared t1 to old version
|
|
use mysqltest;
|
|
select * from t1;
|
|
a
|
|
00000000
|
|
* TEST of REDO+UNDO: normal recovery test (no moving tables under its feet)
|
|
insert into t1 values ("00000000");
|
|
flush table t1;
|
|
* copied t1 for comparison
|
|
lock tables t1 write;
|
|
insert into t1 values ("aaaaaaaaa");
|
|
SET SESSION debug="+d,maria_crash";
|
|
* crashing mysqld intentionally
|
|
set global maria_checkpoint_interval=1;
|
|
ERROR HY000: Lost connection to MySQL server during query
|
|
* recovery happens
|
|
check table t1 extended;
|
|
Table Op Msg_type Msg_text
|
|
mysqltest.t1 check status OK
|
|
* testing that checksum after recovery is as expected
|
|
Checksum-check
|
|
ok
|
|
use mysqltest;
|
|
select * from t1;
|
|
a
|
|
00000000
|
|
00000000
|
|
insert into t1 values ("00000000");
|
|
flush table t1;
|
|
* copied t1 for comparison
|
|
lock tables t1 write;
|
|
insert into t1 values ("aaaaaaaaa");
|
|
SET SESSION debug="+d,maria_flush_whole_page_cache,maria_crash";
|
|
* crashing mysqld intentionally
|
|
set global maria_checkpoint_interval=1;
|
|
ERROR HY000: Lost connection to MySQL server during query
|
|
* recovery happens
|
|
check table t1 extended;
|
|
Table Op Msg_type Msg_text
|
|
mysqltest.t1 check status OK
|
|
* testing that checksum after recovery is as expected
|
|
Checksum-check
|
|
ok
|
|
use mysqltest;
|
|
select * from t1;
|
|
a
|
|
00000000
|
|
00000000
|
|
00000000
|
|
insert into t1 values ("00000000");
|
|
flush table t1;
|
|
* copied t1 for comparison
|
|
lock tables t1 write;
|
|
insert into t1 values ("aaaaaaaaa");
|
|
SET SESSION debug="+d,maria_flush_states,maria_flush_whole_log,maria_crash";
|
|
* crashing mysqld intentionally
|
|
set global maria_checkpoint_interval=1;
|
|
ERROR HY000: Lost connection to MySQL server during query
|
|
* recovery happens
|
|
check table t1 extended;
|
|
Table Op Msg_type Msg_text
|
|
mysqltest.t1 check status OK
|
|
* testing that checksum after recovery is as expected
|
|
Checksum-check
|
|
ok
|
|
use mysqltest;
|
|
select * from t1;
|
|
a
|
|
00000000
|
|
00000000
|
|
00000000
|
|
00000000
|
|
insert into t1 values ("00000000");
|
|
flush table t1;
|
|
* copied t1 for comparison
|
|
lock tables t1 write;
|
|
insert into t1 values ("aaaaaaaaa");
|
|
SET SESSION debug="+d,maria_flush_whole_log,maria_crash";
|
|
* crashing mysqld intentionally
|
|
set global maria_checkpoint_interval=1;
|
|
ERROR HY000: Lost connection to MySQL server during query
|
|
* recovery happens
|
|
check table t1 extended;
|
|
Table Op Msg_type Msg_text
|
|
mysqltest.t1 check status OK
|
|
* testing that checksum after recovery is as expected
|
|
Checksum-check
|
|
ok
|
|
use mysqltest;
|
|
select * from t1;
|
|
a
|
|
00000000
|
|
00000000
|
|
00000000
|
|
00000000
|
|
00000000
|
|
drop table t1;
|
|
* TEST of two REDOs for same page in one REDO group
|
|
* shut down mysqld, removed logs, restarted it
|
|
use mysqltest;
|
|
CREATE TABLE t1 (
|
|
i int,
|
|
b blob default NULL,
|
|
c varchar(6000) default NULL
|
|
) ENGINE=MARIA CHECKSUM=1;
|
|
* copied t1 for feeding_recovery
|
|
INSERT INTO t1 VALUES (1, REPEAT('a', 5000), REPEAT('b', 5000));
|
|
UPDATE t1 SET i=3, b=CONCAT(b,'c') WHERE i=1;
|
|
SELECT LENGTH(b) FROM t1 WHERE i=3;
|
|
LENGTH(b)
|
|
5001
|
|
flush table t1;
|
|
* copied t1 for comparison
|
|
SET SESSION debug="+d,maria_flush_whole_log,maria_crash";
|
|
* crashing mysqld intentionally
|
|
set global maria_checkpoint_interval=1;
|
|
ERROR HY000: Lost connection to MySQL server during query
|
|
* copied t1 back for feeding_recovery
|
|
* recovery happens
|
|
check table t1 extended;
|
|
Table Op Msg_type Msg_text
|
|
mysqltest.t1 check status OK
|
|
* testing that checksum after recovery is as expected
|
|
Checksum-check
|
|
ok
|
|
use mysqltest;
|
|
SELECT LENGTH(b) FROM t1 WHERE i=3;
|
|
LENGTH(b)
|
|
5001
|
|
drop table t1;
|
|
* TEST of INSERT vs state.auto_increment
|
|
* shut down mysqld, removed logs, restarted it
|
|
use mysqltest;
|
|
CREATE TABLE t1 (
|
|
i int auto_increment primary key,
|
|
c varchar(6),
|
|
key(c)
|
|
) ENGINE=MARIA;
|
|
insert into t1 values(null,"b");
|
|
* copied t1 for feeding_recovery
|
|
insert into t1 values(null,"a"), (null,"c"), (null,"d");
|
|
delete from t1 where c="d";
|
|
flush table t1;
|
|
* copied t1 for comparison
|
|
SET SESSION debug="+d,maria_flush_whole_log,maria_crash";
|
|
* crashing mysqld intentionally
|
|
set global maria_checkpoint_interval=1;
|
|
ERROR HY000: Lost connection to MySQL server during query
|
|
* copied t1 back for feeding_recovery
|
|
* recovery happens
|
|
check table t1 extended;
|
|
Table Op Msg_type Msg_text
|
|
mysqltest.t1 check status OK
|
|
* testing that checksum after recovery is as expected
|
|
Checksum-check
|
|
ok
|
|
use mysqltest;
|
|
show create table t1;
|
|
Table Create Table
|
|
t1 CREATE TABLE `t1` (
|
|
`i` int(11) NOT NULL AUTO_INCREMENT,
|
|
`c` varchar(6) DEFAULT NULL,
|
|
PRIMARY KEY (`i`),
|
|
KEY `c` (`c`)
|
|
) ENGINE=MARIA AUTO_INCREMENT=5 DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
|
|
* TEST of UPDATE vs state.auto_increment
|
|
* copied t1 for feeding_recovery
|
|
update t1 set i=15 where c="a";
|
|
flush table t1;
|
|
* copied t1 for comparison
|
|
SET SESSION debug="+d,maria_flush_whole_log,maria_crash";
|
|
* crashing mysqld intentionally
|
|
set global maria_checkpoint_interval=1;
|
|
ERROR HY000: Lost connection to MySQL server during query
|
|
* copied t1 back for feeding_recovery
|
|
* recovery happens
|
|
check table t1 extended;
|
|
Table Op Msg_type Msg_text
|
|
mysqltest.t1 check status OK
|
|
* testing that checksum after recovery is as expected
|
|
Checksum-check
|
|
ok
|
|
use mysqltest;
|
|
show create table t1;
|
|
Table Create Table
|
|
t1 CREATE TABLE `t1` (
|
|
`i` int(11) NOT NULL AUTO_INCREMENT,
|
|
`c` varchar(6) DEFAULT NULL,
|
|
PRIMARY KEY (`i`),
|
|
KEY `c` (`c`)
|
|
) ENGINE=MARIA AUTO_INCREMENT=16 DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
|
|
* TEST of INSERT's rollback vs state.auto_increment
|
|
flush table t1;
|
|
* copied t1 for comparison
|
|
lock tables t1 write;
|
|
insert into t1 values(null, "e");
|
|
SET SESSION debug="+d,maria_flush_whole_log,maria_crash";
|
|
* crashing mysqld intentionally
|
|
set global maria_checkpoint_interval=1;
|
|
ERROR HY000: Lost connection to MySQL server during query
|
|
* recovery happens
|
|
check table t1 extended;
|
|
Table Op Msg_type Msg_text
|
|
mysqltest.t1 check status OK
|
|
* testing that checksum after recovery is as expected
|
|
Checksum-check
|
|
ok
|
|
use mysqltest;
|
|
show create table t1;
|
|
Table Create Table
|
|
t1 CREATE TABLE `t1` (
|
|
`i` int(11) NOT NULL AUTO_INCREMENT,
|
|
`c` varchar(6) DEFAULT NULL,
|
|
PRIMARY KEY (`i`),
|
|
KEY `c` (`c`)
|
|
) ENGINE=MARIA AUTO_INCREMENT=17 DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
|
|
insert into t1 values(null, "f");
|
|
drop table t1;
|
|
* TEST of removing logs manually
|
|
* shut down mysqld, removed logs, restarted it
|
|
use mysqltest;
|
|
* TEST of UNDO_ROW_DELETE preserving rowid
|
|
create table t1(a int) engine=maria;
|
|
insert into t1 values(1),(2);
|
|
flush table t1;
|
|
* copied t1 for comparison
|
|
lock tables t1 write;
|
|
insert into t1 values(3);
|
|
delete from t1 where a in (1,2,3);
|
|
SET SESSION debug="+d,maria_flush_whole_log,maria_crash";
|
|
* crashing mysqld intentionally
|
|
set global maria_checkpoint_interval=1;
|
|
ERROR HY000: Lost connection to MySQL server during query
|
|
* recovery happens
|
|
check table t1 extended;
|
|
Table Op Msg_type Msg_text
|
|
mysqltest.t1 check status OK
|
|
* testing that checksum after recovery is as expected
|
|
Checksum-check
|
|
ok
|
|
use mysqltest;
|
|
drop table t1;
|
|
* TEST of checkpoint
|
|
set global debug="+d,info,query,enter,exit,loop,maria_checkpoint_indirect";
|
|
set global maria_checkpoint_interval=10000;
|
|
create table t1(a int, b varchar(10), index(a,b)) engine=maria;
|
|
insert into t1 values(1,"a"),(2,"b"),(3,"c");
|
|
delete from t1 where b="b";
|
|
update t1 set b="d" where a=1;
|
|
flush table t1;
|
|
* copied t1 for comparison
|
|
lock tables t1 write;
|
|
insert into t1 values(4,"e"),(5,"f"),(6,"g");
|
|
update t1 set b="h" where a=5;
|
|
delete from t1 where b="g";
|
|
show status like "Maria_pagecache_blocks_not_flushed";
|
|
Variable_name Value
|
|
Maria_pagecache_blocks_not_flushed 3
|
|
set global maria_checkpoint_interval=10000;
|
|
update t1 set b="i" where a=5;
|
|
SET SESSION debug="+d,maria_crash";
|
|
* crashing mysqld intentionally
|
|
set global maria_checkpoint_interval=1;
|
|
ERROR HY000: Lost connection to MySQL server during query
|
|
* recovery happens
|
|
check table t1 extended;
|
|
Table Op Msg_type Msg_text
|
|
mysqltest.t1 check status OK
|
|
* testing that checksum after recovery is as expected
|
|
Checksum-check
|
|
ok
|
|
use mysqltest;
|
|
drop table t1;
|
|
Test of REPAIR's implicit commit
|
|
create table t1 (a varchar(100), key(a)) engine=maria;
|
|
insert into t1 values(3);
|
|
flush table t1;
|
|
* copied t1 for comparison
|
|
lock tables t1 write;
|
|
insert into t1 values (1);
|
|
repair table t1;
|
|
Table Op Msg_type Msg_text
|
|
mysqltest.t1 repair status OK
|
|
insert into t1 values(2);
|
|
select * from t1;
|
|
a
|
|
1
|
|
2
|
|
3
|
|
SET SESSION debug="+d,maria_flush_whole_log,maria_flush_whole_page_cache,maria_crash";
|
|
* crashing mysqld intentionally
|
|
set global maria_checkpoint_interval=1;
|
|
ERROR HY000: Lost connection to MySQL server during query
|
|
* recovery happens
|
|
check table t1 extended;
|
|
Table Op Msg_type Msg_text
|
|
mysqltest.t1 check status OK
|
|
* testing that checksum after recovery is as expected
|
|
Checksum-check
|
|
failure
|
|
use mysqltest;
|
|
select * from t1;
|
|
a
|
|
1
|
|
3
|
|
drop table t1;
|
|
* TEST of recovery when crash before bulk-insert-with-repair is committed
|
|
create table t1 (a varchar(100), key(a)) engine=maria;
|
|
create table t2 (a varchar(100)) engine=myisam;
|
|
set rand_seed1=12, rand_seed2=254;
|
|
insert into t2 values (rand());
|
|
insert into t2 select (rand()) from t2;
|
|
insert into t2 select (rand()) from t2;
|
|
insert into t2 select (rand()) from t2;
|
|
insert into t2 select (rand()) from t2;
|
|
insert into t2 select (rand()) from t2;
|
|
insert into t2 select (rand()) from t2;
|
|
insert into t1 values(30);
|
|
flush table t1;
|
|
* copied t1 for comparison
|
|
lock tables t1 write, t2 read;
|
|
delete from t1 limit 1;
|
|
insert into t1 select * from t2;
|
|
SET SESSION debug="+d,maria_flush_whole_log,maria_flush_whole_page_cache,maria_crash";
|
|
* crashing mysqld intentionally
|
|
set global maria_checkpoint_interval=1;
|
|
ERROR HY000: Lost connection to MySQL server during query
|
|
* recovery happens
|
|
check table t1 extended;
|
|
Table Op Msg_type Msg_text
|
|
mysqltest.t1 check status OK
|
|
* testing that checksum after recovery is as expected
|
|
Checksum-check
|
|
ok
|
|
use mysqltest;
|
|
show keys from t1;
|
|
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
|
t1 1 a 1 a A 1 NULL NULL YES BTREE
|
|
drop table t1;
|
|
* TEST of recovery when OPTIMIZE has replaced the index file and crash
|
|
create table t1 (a varchar(100), key(a)) engine=maria;
|
|
insert into t1 select (rand()) from t2;
|
|
flush table t1;
|
|
* copied t1 for comparison
|
|
SET SESSION debug="+d,maria_flush_whole_log,maria_flush_whole_page_cache,maria_crash_sort_index";
|
|
* crashing mysqld intentionally
|
|
optimize table t1;
|
|
ERROR HY000: Lost connection to MySQL server during query
|
|
* recovery happens
|
|
check table t1 extended;
|
|
Table Op Msg_type Msg_text
|
|
mysqltest.t1 check warning Table is marked as crashed and last repair failed
|
|
mysqltest.t1 check status OK
|
|
* testing that checksum after recovery is as expected
|
|
Checksum-check
|
|
ok
|
|
use mysqltest;
|
|
drop table t1, t2;
|
|
drop database mysqltest_for_feeding_recovery;
|
|
drop database mysqltest_for_comparison;
|
|
drop database mysqltest;
|