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