| 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 |
| 7 |
--source include/default_charset.inc |
| 8 |
|
| 9 |
set global aria_log_file_size=4294959104; |
| 10 |
let $MARIA_LOG=../../tmp; |
| 11 |
|
| 12 |
--disable_warnings |
| 13 |
drop database if exists mysqltest; |
| 14 |
--enable_warnings |
| 15 |
create database mysqltest; |
| 16 |
let $mms_tname=t; |
| 17 |
|
| 18 |
# Include scripts can perform SQL. For it to not influence the main test |
| 19 |
# they use a separate connection. This way if they use a DDL it would |
| 20 |
# not autocommit in the main test. |
| 21 |
connect (admin, localhost, root,,mysqltest,,); |
| 22 |
--enable_reconnect |
| 23 |
|
| 24 |
connection default; |
| 25 |
use mysqltest; |
| 26 |
--enable_reconnect |
| 27 |
|
| 28 |
# A sample test |
| 29 |
-- source include/maria_empty_logs.inc |
| 30 |
let $mms_tables=1; |
| 31 |
create table t1 (a varchar(1000)) engine=aria; |
| 32 |
|
| 33 |
--echo * TEST of REDO: see if recovery can reconstruct if we give it an old table |
| 34 |
|
| 35 |
-- source include/maria_make_snapshot_for_feeding_recovery.inc |
| 36 |
# Your committed statements here, which we expect to |
| 37 |
# be reconstructed from the log |
| 38 |
insert into t1 values ("00000000"); |
| 39 |
-- source include/maria_make_snapshot_for_comparison.inc |
| 40 |
# we want recovery to run on the first snapshot made above |
| 41 |
let $mvr_restore_old_snapshot=1; |
| 42 |
# As we did only committed work, we test REDO applying, which could |
| 43 |
# produce a physically identical table. |
| 44 |
let $mms_compare_physically=1; |
| 45 |
let $mvr_debug_option="+d,maria_flush_whole_log,maria_crash"; |
| 46 |
let $mvr_crash_statement= set global aria_checkpoint_interval=1; |
| 47 |
# the script below will trigger recovery and compare checksums |
| 48 |
-- source include/maria_verify_recovery.inc |
| 49 |
let $mms_compare_physically=0; |
| 50 |
# so a SELECT like this is pure visual effect, brings nothing. |
| 51 |
select * from t1; |
| 52 |
|
| 53 |
--echo * TEST of REDO+UNDO: normal recovery test (no moving tables under its feet) |
| 54 |
|
| 55 |
# different types of crash => a loop; here are loop control variables |
| 56 |
let $crash_no_flush=1; |
| 57 |
let $crash_flush_whole_page_cache=0; |
| 58 |
let $crash_flush_states=0; |
| 59 |
let $crash_flush_whole_log=0; |
| 60 |
let $crash_loop=1; |
| 61 |
|
| 62 |
# we want recovery to use the tables as they were at time of crash |
| 63 |
let $mvr_restore_old_snapshot=0; |
| 64 |
# UNDO phase prevents physical comparison, normally, |
| 65 |
# so we'll only use checksums to compare. |
| 66 |
let $mms_compare_physically=0; |
| 67 |
let $mvr_crash_statement= set global aria_checkpoint_interval=1; |
| 68 |
|
| 69 |
# Note that we don't remove logs between iterations. Test is |
| 70 |
# cumulative (each new recovery processes more log records than the previous). |
| 71 |
|
| 72 |
while ($crash_loop) |
| 73 |
{ |
| 74 |
if ($crash_flush_whole_log) |
| 75 |
{ |
| 76 |
let $mvr_debug_option="+d,maria_flush_whole_log,maria_crash"; |
| 77 |
# set up what next iteration should do: |
| 78 |
let $crash_flush_whole_log=0; |
| 79 |
let $crash_loop=0; |
| 80 |
} |
| 81 |
if ($crash_flush_states) |
| 82 |
{ |
| 83 |
let $mvr_debug_option="+d,maria_flush_states,maria_flush_whole_log,maria_crash"; |
| 84 |
let $crash_flush_states=0; |
| 85 |
let $crash_flush_whole_log=1; |
| 86 |
} |
| 87 |
if ($crash_flush_whole_page_cache) |
| 88 |
{ |
| 89 |
let $mvr_debug_option="+d,maria_flush_whole_page_cache,maria_crash"; |
| 90 |
let $crash_flush_whole_page_cache=0; |
| 91 |
let $crash_flush_states=1; |
| 92 |
} |
| 93 |
if ($crash_no_flush) |
| 94 |
{ |
| 95 |
let $mvr_debug_option="+d,maria_crash"; |
| 96 |
let $crash_no_flush=0; |
| 97 |
let $crash_flush_whole_page_cache=1; |
| 98 |
} |
| 99 |
# Your committed statements here |
| 100 |
insert into t1 values ("00000000"); |
| 101 |
-- source include/maria_make_snapshot_for_comparison.inc |
| 102 |
# Your statements which we expect to be rolled back |
| 103 |
lock tables t1 write; |
| 104 |
insert into t1 values ("aaaaaaaaa"); |
| 105 |
-- source include/maria_verify_recovery.inc |
| 106 |
select * from t1; |
| 107 |
} |
| 108 |
|
| 109 |
drop table t1; |
| 110 |
|
| 111 |
# what did we compare above: |
| 112 |
# - checksum: tells that the tables contain the same amount of rows |
| 113 |
# and same data in rows |
| 114 |
# - index: no, neither state nor pages were compared |
| 115 |
# - bitmap pages: the REPAIR QUICK done above very probably checks |
| 116 |
# that bitmap reflects page occupation; do we need to do physical |
| 117 |
# compare? |
| 118 |
# - page LSN: not compared; we should compare that page's LSN in new |
| 119 |
# table is >= page's LSN in old table (it can be >, due to UNDO phase) |
| 120 |
# we had a bug where new page's LSN was 0... todo. |
| 121 |
|
| 122 |
# |
| 123 |
# Test for this bug: an UPDATE purges and rewrites a tail page, and |
| 124 |
# recovery applied the purge, stamped page with UNDO's LSN, thus |
| 125 |
# the rewrite was ignored. |
| 126 |
# |
| 127 |
|
| 128 |
--echo * TEST of two REDOs for same page in one REDO group |
| 129 |
-- source include/maria_empty_logs.inc |
| 130 |
let $mms_tables=1; |
| 131 |
CREATE TABLE t1 ( |
| 132 |
i int, |
| 133 |
b blob default NULL, |
| 134 |
c varchar(6000) default NULL |
| 135 |
) ENGINE=ARIA CHECKSUM=1; |
| 136 |
-- source include/maria_make_snapshot_for_feeding_recovery.inc |
| 137 |
INSERT INTO t1 VALUES (1, REPEAT('a', 5000), REPEAT('b', 5000)); |
| 138 |
UPDATE t1 SET i=3, b=CONCAT(b,'c') WHERE i=1; |
| 139 |
SELECT LENGTH(b) FROM t1 WHERE i=3; |
| 140 |
-- source include/maria_make_snapshot_for_comparison.inc |
| 141 |
# we want recovery to run on the first snapshot made above |
| 142 |
let $mvr_restore_old_snapshot=1; |
| 143 |
let $mms_compare_physically=0; |
| 144 |
let $mvr_debug_option="+d,maria_flush_whole_log,maria_crash"; |
| 145 |
let $mvr_crash_statement= set global aria_checkpoint_interval=1; |
| 146 |
-- source include/maria_verify_recovery.inc |
| 147 |
SELECT LENGTH(b) FROM t1 WHERE i=3; |
| 148 |
drop table t1; |
| 149 |
|
| 150 |
# Test that INSERT's effect on auto-increment is recovered |
| 151 |
--echo * TEST of INSERT vs state.auto_increment |
| 152 |
-- source include/maria_empty_logs.inc |
| 153 |
let $mms_tables=1; |
| 154 |
CREATE TABLE t1 ( |
| 155 |
i int auto_increment primary key, |
| 156 |
c varchar(6), |
| 157 |
key(c) |
| 158 |
) ENGINE=ARIA; |
| 159 |
insert into t1 values(null,"b"); |
| 160 |
-- source include/maria_make_snapshot_for_feeding_recovery.inc |
| 161 |
insert into t1 values(null,"a"), (null,"c"), (null,"d"); |
| 162 |
# With this DELETE we also verify that Recovery cares only about INSERTs |
| 163 |
delete from t1 where c="d"; |
| 164 |
-- source include/maria_make_snapshot_for_comparison.inc |
| 165 |
let $mvr_restore_old_snapshot=1; |
| 166 |
let $mms_compare_physically=0; |
| 167 |
let $mvr_debug_option="+d,maria_flush_whole_log,maria_crash"; |
| 168 |
let $mvr_crash_statement= set global aria_checkpoint_interval=1; |
| 169 |
-- source include/maria_verify_recovery.inc |
| 170 |
show create table t1; |
| 171 |
|
| 172 |
# Test that UPDATE's effect on auto-increment is recovered |
| 173 |
--echo * TEST of UPDATE vs state.auto_increment |
| 174 |
-- source include/maria_make_snapshot_for_feeding_recovery.inc |
| 175 |
update t1 set i=15 where c="a"; |
| 176 |
-- source include/maria_make_snapshot_for_comparison.inc |
| 177 |
let $mvr_restore_old_snapshot=1; |
| 178 |
let $mms_compare_physically=0; |
| 179 |
let $mvr_debug_option="+d,maria_flush_whole_log,maria_crash"; |
| 180 |
let $mvr_crash_statement= set global aria_checkpoint_interval=1; |
| 181 |
-- source include/maria_verify_recovery.inc |
| 182 |
show create table t1; |
| 183 |
|
| 184 |
# Test that INSERT's rollback does not set auto-increment counter to 1 |
| 185 |
# (BUG#34106) |
| 186 |
--echo * TEST of INSERT's rollback vs state.auto_increment |
| 187 |
-- source include/maria_make_snapshot_for_comparison.inc |
| 188 |
let $mvr_restore_old_snapshot=0; |
| 189 |
let $mms_compare_physically=0; |
| 190 |
let $mvr_debug_option="+d,maria_flush_whole_log,maria_crash"; |
| 191 |
let $mvr_crash_statement= set global aria_checkpoint_interval=1; |
| 192 |
lock tables t1 write; |
| 193 |
insert into t1 values(null, "e"); |
| 194 |
-- source include/maria_verify_recovery.inc |
| 195 |
show create table t1; |
| 196 |
insert into t1 values(null, "f"); |
| 197 |
drop table t1; |
| 198 |
|
| 199 |
--echo Test that bulk insert works with recovery |
| 200 |
let $mms_tables=2; |
| 201 |
|
| 202 |
CREATE TABLE t1 (i int, key(i)) TRANSACTIONAL=1 ENGINE=ARIA; |
| 203 |
CREATE TABLE t2 (i int, key(i)) TRANSACTIONAL=1 ENGINE=ARIA; |
| 204 |
-- source include/maria_make_snapshot_for_feeding_recovery.inc |
| 205 |
insert into t2 values |
| 206 |
(0), (1), (2), (3), (4), (5), (6), (7), (8), (9), |
| 207 |
(0), (1), (2), (3), (4), (5), (6), (7), (8), (9), |
| 208 |
(0), (1), (2), (3), (4), (5), (6), (7), (8), (9), |
| 209 |
(0), (1), (2), (3), (4), (5), (6), (7), (8), (9), |
| 210 |
(0), (1), (3), (3), (4), (5), (6), (7), (8), (9), |
| 211 |
(0), (1), (2), (3), (4), (5), (6), (7), (8), (9), |
| 212 |
(0), (1), (2), (3), (4), (5), (6), (7), (8), (9), |
| 213 |
(0), (1), (2), (3), (4), (5), (6), (7), (8), (9), |
| 214 |
(0), (1), (2), (3), (4), (5), (6), (7), (8), (9), |
| 215 |
(0), (1), (2), (3), (4), (5), (6), (7), (8), (9); |
| 216 |
insert into t1 select * from t2; |
| 217 |
insert into t2 select * from t2; |
| 218 |
let $mvr_restore_old_snapshot=0; |
| 219 |
let $mms_compare_physically=0; |
| 220 |
let $mvr_debug_option="+d,maria_flush_whole_log,maria_crash"; |
| 221 |
let $mvr_crash_statement= set global aria_checkpoint_interval=1; |
| 222 |
let $mms_tables=0; |
| 223 |
-- source include/maria_verify_recovery.inc |
| 224 |
select count(*) from t1; |
| 225 |
select count(*) from t2; |
| 226 |
check table t2; |
| 227 |
drop table t1,t2; |
| 228 |
|
| 229 |
# clean up everything |
| 230 |
let $mms_purpose=feeding_recovery; |
| 231 |
eval drop database mysqltest_for_$mms_purpose; |
| 232 |
let $mms_purpose=comparison; |
| 233 |
eval drop database mysqltest_for_$mms_purpose; |
| 234 |
drop database mysqltest; |