~jlukas79/+junk/mysql-server

« back to all changes in this revision

Viewing changes to mysql-test/t/maria-recovery.test

manual merge 6.0-main --> 6.0-bka-review

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
set global maria_log_file_size=4294967295;
 
9
let $MARIA_LOG=../tmp;
 
10
 
 
11
--disable_warnings
 
12
drop database if exists mysqltest;
 
13
--enable_warnings
 
14
create database mysqltest;
 
15
let $mms_tname=t;
 
16
 
 
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,,);
 
21
--enable_reconnect
 
22
 
 
23
connection default;
 
24
use mysqltest;
 
25
--enable_reconnect
 
26
 
 
27
# A sample test
 
28
-- source include/maria_empty_logs.inc
 
29
let $mms_tables=1;
 
30
create table t1 (a varchar(1000)) engine=maria;
 
31
 
 
32
--echo * TEST of REDO: see if recovery can reconstruct if we give it an old table
 
33
 
 
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.
 
50
select * from t1;
 
51
 
 
52
--echo * TEST of REDO+UNDO: normal recovery test (no moving tables under its feet)
 
53
 
 
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;
 
59
let $crash_loop=1;
 
60
 
 
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;
 
67
 
 
68
# Note that we don't remove logs between iterations. Test is
 
69
# cumulative (each new recovery processes more log records than the previous).
 
70
 
 
71
while ($crash_loop)
 
72
{
 
73
  if ($crash_flush_whole_log)
 
74
  {
 
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;
 
78
     let $crash_loop=0;
 
79
  }
 
80
  if ($crash_flush_states)
 
81
  {
 
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;
 
85
  }
 
86
  if ($crash_flush_whole_page_cache)
 
87
  {
 
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;
 
91
  }
 
92
  if ($crash_no_flush)
 
93
  {
 
94
     let $mvr_debug_option="+d,maria_crash";
 
95
     let $crash_no_flush=0;
 
96
     let $crash_flush_whole_page_cache=1;
 
97
  }
 
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
 
105
  select * from t1;
 
106
}
 
107
 
 
108
drop table t1;
 
109
 
 
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
 
116
# compare?
 
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.
 
120
 
 
121
#
 
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.
 
125
#
 
126
 
 
127
--echo * TEST of two REDOs for same page in one REDO group
 
128
-- source include/maria_empty_logs.inc
 
129
let $mms_tables=1;
 
130
CREATE TABLE t1 (
 
131
  i int,
 
132
  b blob default NULL,
 
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;
 
147
drop table t1;
 
148
 
 
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
 
152
let $mms_tables=1;
 
153
CREATE TABLE t1 (
 
154
  i int auto_increment primary key,
 
155
  c varchar(6),
 
156
  key(c)
 
157
) ENGINE=MARIA;
 
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;
 
170
 
 
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;
 
182
 
 
183
# Test that INSERT's rollback does not set auto-increment counter to 1
 
184
# (BUG#34106)
 
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");
 
196
drop table t1;
 
197
 
 
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;