| 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 |
|
| 8 |
call mtr.add_suppression("File '.*aria_log.000.*' not found \\(Errcode: 2 .*\\)"); |
| 9 |
call mtr.add_suppression("Table '.\/mysqltest\/t_corrupted1' is crashed, skipping it. Please repair it with aria_chk -r"); |
| 10 |
|
| 11 |
set global aria_log_file_size=4294959104; |
| 12 |
let $MARIA_LOG=../../tmp; |
| 13 |
|
| 14 |
--disable_warnings |
| 15 |
drop database if exists mysqltest; |
| 16 |
--enable_warnings |
| 17 |
create database mysqltest; |
| 18 |
let $mms_tname=t; |
| 19 |
|
| 20 |
# Include scripts can perform SQL. For it to not influence the main test |
| 21 |
# they use a separate connection. This way if they use a DDL it would |
| 22 |
# not autocommit in the main test. |
| 23 |
connect (admin, 127.0.0.1, root,,mysqltest,,); |
| 24 |
--enable_reconnect |
| 25 |
|
| 26 |
connection default; |
| 27 |
use mysqltest; |
| 28 |
--enable_reconnect |
| 29 |
|
| 30 |
let $mms_tables=1; |
| 31 |
let $mvr_restore_old_snapshot=0; |
| 32 |
let $mms_compare_physically=0; |
| 33 |
let $mvr_debug_option="+d,maria_flush_whole_log,maria_crash"; |
| 34 |
let $mvr_crash_statement= set global aria_checkpoint_interval=1; |
| 35 |
|
| 36 |
# Test of removing logs manually |
| 37 |
--echo * TEST of removing logs manually |
| 38 |
let $mel_keep_control_file=1; |
| 39 |
# this will shut mysqld down cleanly (so, take a checkpoint) and |
| 40 |
# remove only logs; at restart Aria will create a new log with a high |
| 41 |
# number |
| 42 |
-- source include/maria_empty_logs.inc |
| 43 |
let $mel_keep_control_file=0; |
| 44 |
# next test will help us verify that a next recovery is ok |
| 45 |
|
| 46 |
--echo * TEST of UNDO_ROW_DELETE preserving rowid |
| 47 |
# we want recovery to use the tables as they were at time of crash |
| 48 |
let $mvr_restore_old_snapshot=0; |
| 49 |
# UNDO phase prevents physical comparison, normally, |
| 50 |
# so we'll only use checksums to compare. |
| 51 |
let $mms_compare_physically=0; |
| 52 |
let $mvr_crash_statement= set global aria_checkpoint_interval=1; |
| 53 |
create table t1(a int) engine=aria; |
| 54 |
insert into t1 values(1),(2); |
| 55 |
-- source include/maria_make_snapshot_for_comparison.inc |
| 56 |
lock tables t1 write; |
| 57 |
insert into t1 values(3); |
| 58 |
delete from t1 where a in (1,2,3); |
| 59 |
-- source include/maria_verify_recovery.inc |
| 60 |
drop table t1; |
| 61 |
|
| 62 |
# A basic checkpoint test |
| 63 |
--echo * TEST of checkpoint |
| 64 |
# Don't take a full checkpoints, we want to test checkpoint vs dirty pages |
| 65 |
set global debug_dbug="+d,info,query,enter,exit,loop,maria_checkpoint_indirect"; |
| 66 |
# restart checkpoint thread for it to notice the above |
| 67 |
set global aria_checkpoint_interval=10000; |
| 68 |
create table t1(a int, b varchar(10), index(a,b)) engine=aria; |
| 69 |
insert into t1 values(1,"a"),(2,"b"),(3,"c"); |
| 70 |
delete from t1 where b="b"; |
| 71 |
update t1 set b="d" where a=1; |
| 72 |
-- source include/maria_make_snapshot_for_comparison.inc |
| 73 |
lock tables t1 write; |
| 74 |
insert into t1 values(4,"e"),(5,"f"),(6,"g"); |
| 75 |
update t1 set b="h" where a=5; |
| 76 |
delete from t1 where b="g"; |
| 77 |
show status like "Aria_pagecache_blocks_not_flushed"; |
| 78 |
# force a checkpoint; there should be dirty pages and an open transaction |
| 79 |
set global aria_checkpoint_interval=10000; |
| 80 |
# do some more work |
| 81 |
update t1 set b="i" where a=5; |
| 82 |
let $mvr_restore_old_snapshot=0; |
| 83 |
let $mms_compare_physically=0; |
| 84 |
let $mvr_debug_option="+d,maria_crash"; |
| 85 |
let $mvr_crash_statement= set global aria_checkpoint_interval=1; |
| 86 |
# Now we have a recovery, which should use the checkpoint record |
| 87 |
# and its dirty pages list. |
| 88 |
-- source include/maria_verify_recovery.inc |
| 89 |
drop table t1; |
| 90 |
|
| 91 |
--echo Test of REPAIR's implicit commit |
| 92 |
let $mms_tables=1; |
| 93 |
create table t1 (a varchar(100), key(a)) engine=aria; |
| 94 |
let $mvr_restore_old_snapshot=0; |
| 95 |
let $mms_compare_physically=0; |
| 96 |
let $mvr_crash_statement= set global aria_checkpoint_interval=1; |
| 97 |
|
| 98 |
let $mvr_debug_option="+d,maria_flush_whole_log,maria_flush_whole_page_cache,maria_crash"; |
| 99 |
insert into t1 values(3); |
| 100 |
-- source include/maria_make_snapshot_for_comparison.inc |
| 101 |
lock tables t1 write; |
| 102 |
insert into t1 values (1); |
| 103 |
repair table t1; |
| 104 |
insert into t1 values(2); |
| 105 |
select * from t1; |
| 106 |
|
| 107 |
# checksum comparison failure is expected, SELECT output matters |
| 108 |
-- source include/maria_verify_recovery.inc |
| 109 |
# 2 should be missing (rolled back) but 1 should be committed |
| 110 |
select * from t1; |
| 111 |
drop table t1; |
| 112 |
|
| 113 |
--echo * TEST of recovery when crash before bulk-insert-with-repair is committed |
| 114 |
create table t1 (a varchar(100), key(a)) engine=aria; |
| 115 |
create table t2 (a varchar(100)) engine=myisam; |
| 116 |
let $mvr_restore_old_snapshot=0; |
| 117 |
let $mms_compare_physically=0; |
| 118 |
let $mvr_crash_statement= set global aria_checkpoint_interval=1; |
| 119 |
let $mvr_debug_option="+d,maria_flush_whole_log,maria_flush_whole_page_cache,maria_crash"; |
| 120 |
set rand_seed1=12, rand_seed2=254; # repeatable |
| 121 |
insert into t2 values (rand()); |
| 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 t2 select (rand()) from t2; |
| 126 |
insert into t2 select (rand()) from t2; |
| 127 |
insert into t2 select (rand()) from t2; |
| 128 |
insert into t1 values(30); |
| 129 |
-- source include/maria_make_snapshot_for_comparison.inc |
| 130 |
lock tables t1 write, t2 read; |
| 131 |
delete from t1 limit 1; |
| 132 |
# 127 rows in t2, >100, so this will use repair-at-end |
| 133 |
select count(*) from t1; |
| 134 |
insert into t1 select * from t2; |
| 135 |
-- source include/maria_verify_recovery.inc |
| 136 |
show keys from t1; # should be enabled |
| 137 |
select count(*) from t1; |
| 138 |
drop table t1; |
| 139 |
|
| 140 |
--echo * TEST of recovery when OPTIMIZE has replaced the index file and crash |
| 141 |
create table t_corrupted1 (a varchar(100), key(a)) engine=aria; |
| 142 |
# we use a special name because this test portion will generate |
| 143 |
# corruption warnings, which we tell mtr_report.pl to ignore by |
| 144 |
# putting the message in mtr_report.pl, but we don't want to it ignore |
| 145 |
# corruption messages of other tests, hence the special name |
| 146 |
# 't_corrupted' and not just 't'. |
| 147 |
let $mms_tname=t_corrupted; |
| 148 |
let $mvr_restore_old_snapshot=0; |
| 149 |
let $mms_compare_physically=0; |
| 150 |
let $mvr_crash_statement= optimize table t_corrupted1; |
| 151 |
let $mvr_debug_option="+d,maria_flush_whole_log,maria_flush_whole_page_cache,maria_crash_sort_index"; |
| 152 |
insert into t_corrupted1 select (rand()) from t2; |
| 153 |
-- source include/maria_make_snapshot_for_comparison.inc |
| 154 |
# Recovery will not fix the table, but we expect to see it marked |
| 155 |
# "crashed on repair". |
| 156 |
# Because crash is mild, the table is actually not corrupted, so the |
| 157 |
# "check table extended" done below fixes the table. |
| 158 |
-- source include/maria_verify_recovery.inc |
| 159 |
drop table t_corrupted1, t2; |
| 160 |
|
| 161 |
# clean up everything |
| 162 |
let $mms_purpose=comparison; |
| 163 |
eval drop database mysqltest_for_$mms_purpose; |
| 164 |
drop database mysqltest; |