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, localhost, root,,mysqltest,,);
28
-- source include/maria_empty_logs.inc
30
create table t1 (a varchar(1000)) engine=maria;
32
--echo * TEST of REDO: see if recovery can reconstruct if we give it an old table
34
-- source include/maria_make_snapshot_for_feeding_recovery.inc
35
# Your committed statements here, which we expect to
36
# be reconstructed from the log
37
insert into t1 values ("00000000");
38
-- source include/maria_make_snapshot_for_comparison.inc
39
# we want recovery to run on the first snapshot made above
40
let $mvr_restore_old_snapshot=1;
41
# As we did only committed work, we test REDO applying, which could
42
# produce a physically identical table.
43
let $mms_compare_physically=1;
44
let $mvr_debug_option="+d,maria_flush_whole_log,maria_crash";
45
let $mvr_crash_statement= set global maria_checkpoint_interval=1;
46
# the script below will trigger recovery and compare checksums
47
-- source include/maria_verify_recovery.inc
48
let $mms_compare_physically=0;
49
# so a SELECT like this is pure visual effect, brings nothing.
52
--echo * TEST of REDO+UNDO: normal recovery test (no moving tables under its feet)
54
# different types of crash => a loop; here are loop control variables
55
let $crash_no_flush=1;
56
let $crash_flush_whole_page_cache=0;
57
let $crash_flush_states=0;
58
let $crash_flush_whole_log=0;
61
# we want recovery to use the tables as they were at time of crash
62
let $mvr_restore_old_snapshot=0;
63
# UNDO phase prevents physical comparison, normally,
64
# so we'll only use checksums to compare.
65
let $mms_compare_physically=0;
66
let $mvr_crash_statement= set global maria_checkpoint_interval=1;
68
# Note that we don't remove logs between iterations. Test is
69
# cumulative (each new recovery processes more log records than the previous).
73
if ($crash_flush_whole_log)
75
let $mvr_debug_option="+d,maria_flush_whole_log,maria_crash";
76
# set up what next iteration should do:
77
let $crash_flush_whole_log=0;
80
if ($crash_flush_states)
82
let $mvr_debug_option="+d,maria_flush_states,maria_flush_whole_log,maria_crash";
83
let $crash_flush_states=0;
84
let $crash_flush_whole_log=1;
86
if ($crash_flush_whole_page_cache)
88
let $mvr_debug_option="+d,maria_flush_whole_page_cache,maria_crash";
89
let $crash_flush_whole_page_cache=0;
90
let $crash_flush_states=1;
94
let $mvr_debug_option="+d,maria_crash";
95
let $crash_no_flush=0;
96
let $crash_flush_whole_page_cache=1;
98
# Your committed statements here
99
insert into t1 values ("00000000");
100
-- source include/maria_make_snapshot_for_comparison.inc
101
# Your statements which we expect to be rolled back
102
lock tables t1 write;
103
insert into t1 values ("aaaaaaaaa");
104
-- source include/maria_verify_recovery.inc
110
# what did we compare above:
111
# - checksum: tells that the tables contain the same amount of rows
112
# and same data in rows
113
# - index: no, neither state nor pages were compared
114
# - bitmap pages: the REPAIR QUICK done above very probably checks
115
# that bitmap reflects page occupation; do we need to do physical
117
# - page LSN: not compared; we should compare that page's LSN in new
118
# table is >= page's LSN in old table (it can be >, due to UNDO phase)
119
# we had a bug where new page's LSN was 0... todo.
122
# Test for this bug: an UPDATE purges and rewrites a tail page, and
123
# recovery applied the purge, stamped page with UNDO's LSN, thus
124
# the rewrite was ignored.
127
--echo * TEST of two REDOs for same page in one REDO group
128
-- source include/maria_empty_logs.inc
133
c varchar(6000) default NULL
134
) ENGINE=MARIA CHECKSUM=1;
135
-- source include/maria_make_snapshot_for_feeding_recovery.inc
136
INSERT INTO t1 VALUES (1, REPEAT('a', 5000), REPEAT('b', 5000));
137
UPDATE t1 SET i=3, b=CONCAT(b,'c') WHERE i=1;
138
SELECT LENGTH(b) FROM t1 WHERE i=3;
139
-- source include/maria_make_snapshot_for_comparison.inc
140
# we want recovery to run on the first snapshot made above
141
let $mvr_restore_old_snapshot=1;
142
let $mms_compare_physically=0;
143
let $mvr_debug_option="+d,maria_flush_whole_log,maria_crash";
144
let $mvr_crash_statement= set global maria_checkpoint_interval=1;
145
-- source include/maria_verify_recovery.inc
146
SELECT LENGTH(b) FROM t1 WHERE i=3;
149
# Test that INSERT's effect on auto-increment is recovered
150
--echo * TEST of INSERT vs state.auto_increment
151
-- source include/maria_empty_logs.inc
154
i int auto_increment primary key,
158
insert into t1 values(null,"b");
159
-- source include/maria_make_snapshot_for_feeding_recovery.inc
160
insert into t1 values(null,"a"), (null,"c"), (null,"d");
161
# With this DELETE we also verify that Recovery cares only about INSERTs
162
delete from t1 where c="d";
163
-- source include/maria_make_snapshot_for_comparison.inc
164
let $mvr_restore_old_snapshot=1;
165
let $mms_compare_physically=0;
166
let $mvr_debug_option="+d,maria_flush_whole_log,maria_crash";
167
let $mvr_crash_statement= set global maria_checkpoint_interval=1;
168
-- source include/maria_verify_recovery.inc
169
show create table t1;
171
# Test that UPDATE's effect on auto-increment is recovered
172
--echo * TEST of UPDATE vs state.auto_increment
173
-- source include/maria_make_snapshot_for_feeding_recovery.inc
174
update t1 set i=15 where c="a";
175
-- source include/maria_make_snapshot_for_comparison.inc
176
let $mvr_restore_old_snapshot=1;
177
let $mms_compare_physically=0;
178
let $mvr_debug_option="+d,maria_flush_whole_log,maria_crash";
179
let $mvr_crash_statement= set global maria_checkpoint_interval=1;
180
-- source include/maria_verify_recovery.inc
181
show create table t1;
183
# Test that INSERT's rollback does not set auto-increment counter to 1
185
--echo * TEST of INSERT's rollback vs state.auto_increment
186
-- source include/maria_make_snapshot_for_comparison.inc
187
let $mvr_restore_old_snapshot=0;
188
let $mms_compare_physically=0;
189
let $mvr_debug_option="+d,maria_flush_whole_log,maria_crash";
190
let $mvr_crash_statement= set global maria_checkpoint_interval=1;
191
lock tables t1 write;
192
insert into t1 values(null, "e");
193
-- source include/maria_verify_recovery.inc
194
show create table t1;
195
insert into t1 values(null, "f");
198
# clean up everything
199
let $mms_purpose=feeding_recovery;
200
eval drop database mysqltest_for_$mms_purpose;
201
let $mms_purpose=comparison;
202
eval drop database mysqltest_for_$mms_purpose;
203
drop database mysqltest;