1
--source include/not_embedded.inc
2
# Don't test this under valgrind, memory leaks will occur as we crash
3
--source include/not_valgrind.inc
4
# Binary must be compiled with debug for crash to occur
5
--source include/have_debug.inc
6
--source include/have_maria.inc
8
set global maria_log_file_size=4294967295;
12
drop database if exists mysqltest;
14
create database mysqltest;
17
# Include scripts can perform SQL. For it to not influence the main test
18
# they use a separate connection. This way if they use a DDL it would
19
# not autocommit in the main test.
20
connect (admin, 127.0.0.1, root,,mysqltest,,);
28
let $mvr_restore_old_snapshot=0;
29
let $mms_compare_physically=0;
30
let $mvr_debug_option="+d,maria_flush_whole_log,maria_crash";
31
let $mvr_crash_statement= set global maria_checkpoint_interval=1;
33
# Test of removing logs manually
34
--echo * TEST of removing logs manually
35
let $mel_keep_control_file=1;
36
# this will shut mysqld down cleanly (so, take a checkpoint) and
37
# remove only logs; at restart Maria will create a new log with a high
39
-- source include/maria_empty_logs.inc
40
let $mel_keep_control_file=0;
41
# next test will help us verify that a next recovery is ok
43
--echo * TEST of UNDO_ROW_DELETE preserving rowid
44
# we want recovery to use the tables as they were at time of crash
45
let $mvr_restore_old_snapshot=0;
46
# UNDO phase prevents physical comparison, normally,
47
# so we'll only use checksums to compare.
48
let $mms_compare_physically=0;
49
let $mvr_crash_statement= set global maria_checkpoint_interval=1;
50
create table t1(a int) engine=maria;
51
insert into t1 values(1),(2);
52
-- source include/maria_make_snapshot_for_comparison.inc
54
insert into t1 values(3);
55
delete from t1 where a in (1,2,3);
56
-- source include/maria_verify_recovery.inc
59
# A basic checkpoint test
60
--echo * TEST of checkpoint
61
# Don't take a full checkpoints, we want to test checkpoint vs dirty pages
62
set global debug="+d,info,query,enter,exit,loop,maria_checkpoint_indirect";
63
# restart checkpoint thread for it to notice the above
64
set global maria_checkpoint_interval=10000;
65
create table t1(a int, b varchar(10), index(a,b)) engine=maria;
66
insert into t1 values(1,"a"),(2,"b"),(3,"c");
67
delete from t1 where b="b";
68
update t1 set b="d" where a=1;
69
-- source include/maria_make_snapshot_for_comparison.inc
71
insert into t1 values(4,"e"),(5,"f"),(6,"g");
72
update t1 set b="h" where a=5;
73
delete from t1 where b="g";
74
show status like "Maria_pagecache_blocks_not_flushed";
75
# force a checkpoint; there should be dirty pages and an open transaction
76
set global maria_checkpoint_interval=10000;
78
update t1 set b="i" where a=5;
79
let $mvr_restore_old_snapshot=0;
80
let $mms_compare_physically=0;
81
let $mvr_debug_option="+d,maria_crash";
82
let $mvr_crash_statement= set global maria_checkpoint_interval=1;
83
# Now we have a recovery, which should use the checkpoint record
84
# and its dirty pages list.
85
-- source include/maria_verify_recovery.inc
88
--echo Test of REPAIR's implicit commit
90
create table t1 (a varchar(100), key(a)) engine=maria;
91
let $mvr_restore_old_snapshot=0;
92
let $mms_compare_physically=0;
93
let $mvr_crash_statement= set global maria_checkpoint_interval=1;
95
let $mvr_debug_option="+d,maria_flush_whole_log,maria_flush_whole_page_cache,maria_crash";
96
insert into t1 values(3);
97
-- source include/maria_make_snapshot_for_comparison.inc
99
insert into t1 values (1);
101
insert into t1 values(2);
104
# checksum comparison failure is expected, SELECT output matters
105
-- source include/maria_verify_recovery.inc
106
# 2 should be missing (rolled back) but 1 should be committed
110
--echo * TEST of recovery when crash before bulk-insert-with-repair is committed
111
create table t1 (a varchar(100), key(a)) engine=maria;
112
create table t2 (a varchar(100)) engine=myisam;
113
let $mvr_restore_old_snapshot=0;
114
let $mms_compare_physically=0;
115
let $mvr_crash_statement= set global maria_checkpoint_interval=1;
116
let $mvr_debug_option="+d,maria_flush_whole_log,maria_flush_whole_page_cache,maria_crash";
117
set rand_seed1=12, rand_seed2=254; # repeatable
118
insert into t2 values (rand());
119
insert into t2 select (rand()) from t2;
120
insert into t2 select (rand()) from t2;
121
insert into t2 select (rand()) from t2;
122
insert into t2 select (rand()) from t2;
123
insert into t2 select (rand()) from t2;
124
insert into t2 select (rand()) from t2;
125
insert into t1 values(30);
126
-- source include/maria_make_snapshot_for_comparison.inc
127
lock tables t1 write, t2 read;
128
delete from t1 limit 1;
129
# 127 rows in t2, >100, so this will use repair-at-end
130
insert into t1 select * from t2;
131
-- source include/maria_verify_recovery.inc
132
show keys from t1; # should be enabled
135
--echo * TEST of recovery when OPTIMIZE has replaced the index file and crash
136
create table t_corrupted1 (a varchar(100), key(a)) engine=maria;
137
# we use a special name because this test portion will generate
138
# corruption warnings, which we tell mtr_report.pl to ignore by
139
# putting the message in mtr_report.pl, but we don't want to it ignore
140
# corruption messages of other tests, hence the special name
141
# 't_corrupted' and not just 't'.
142
let $mms_tname=t_corrupted;
143
let $mvr_restore_old_snapshot=0;
144
let $mms_compare_physically=0;
145
let $mvr_crash_statement= optimize table t_corrupted1;
146
let $mvr_debug_option="+d,maria_flush_whole_log,maria_flush_whole_page_cache,maria_crash_sort_index";
147
insert into t_corrupted1 select (rand()) from t2;
148
-- source include/maria_make_snapshot_for_comparison.inc
149
# Recovery will not fix the table, but we expect to see it marked
150
# "crashed on repair".
151
# Because crash is mild, the table is actually not corrupted, so the
152
# "check table extended" done below fixes the table.
153
-- source include/maria_verify_recovery.inc
154
drop table t_corrupted1, t2;
156
# clean up everything
157
let $mms_purpose=comparison;
158
eval drop database mysqltest_for_$mms_purpose;
159
drop database mysqltest;