summaryrefslogtreecommitdiffstats
path: root/mysql-test/suite/innodb/t/blob-crash.test
blob: 77787a347459010e730737177ee4c271942229c8 (plain)
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
--source include/innodb_page_size_small.inc
--source include/no_valgrind_without_big.inc

let $have_debug_sync=`select count(*) = 1 from information_schema.session_variables where variable_name = 'debug_sync' and variable_value like 'on %'`;

--echo #
--echo # Bug #16963396 INNODB: USE OF LARGE EXTERNALLY-STORED FIELDS MAKES
--echo # CRASH RECOVERY LOSE DATA
--echo #

# ..........................................................................

--echo #
--echo # Uncompressed Table - Insert Operation - Crash Test
--echo # Fresh insert with blobs
--echo #

CREATE TABLE t1 (a BIGINT PRIMARY KEY, b LONGBLOB) ENGINE=InnoDB;

# Insert a few rows (it doesn't really matter how many). These transactions
# are committed once they are acked, so they should not be lost.
INSERT INTO t1 (a, b) VALUES (1, repeat('^', 40000));
INSERT INTO t1 (a, b) VALUES (2, '2');
INSERT INTO t1 (a, b) VALUES (3, '3');
INSERT INTO t1 (a, b) VALUES (4, '4');
INSERT INTO t1 (a, b) VALUES (5, '5');

# The BLOB insert will fail, and should disappear. However no data committed
# up to this point should be lost.
begin;
INSERT INTO t1 (a, b) VALUES (6, REPEAT('a', 4*1024*1024));

let $shutdown_timeout=0;
let $restart_noprint=2;
--source include/restart_mysqld.inc

SELECT a, right(b, 50) FROM t1;

# ..........................................................................

--echo #
--echo # Uncompressed Table - UPDATE Operation - Crash Test
--echo # Update of non-blob column so that blob is needed.
--echo #

# The BLOB update will fail, and should disappear. However no data committed
# up to this point should be lost.
begin;
UPDATE t1 set b = REPEAT('a', 4*1024*1024) where a = 5 ;

let $shutdown_timeout=0;
--source include/restart_mysqld.inc

SELECT a, right(b, 50) FROM t1;

# ..........................................................................

--echo #
--echo # Uncompressed Table - UPDATE Operation - Crash Test
--echo # Update of blob column to blob.
--echo #

# The BLOB update will fail, and should disappear. However no data committed
# up to this point should be lost.
connect (con1,localhost,root,,);
begin;
UPDATE t1 set b = REPEAT('$', 50000) where a = 1;

connection default;
SET GLOBAL innodb_flush_log_at_trx_commit=1;
UPDATE t1 SET b='five' WHERE a=5;

let $shutdown_timeout=0;
--source include/restart_mysqld.inc

disconnect con1;

SELECT a, right(b, 50) FROM t1;

# ..........................................................................

--echo #
--echo # Uncompressed Table - Rollback of UPDATE operation
--echo # Update moves offpage data to inline data.
--echo #

create table t2 (f1 bigint primary key, f2 longblob, f3 longblob,
  index(f2(10), f3(10))) engine=innodb;

insert into t2 values (10, repeat('.', 40000), repeat('?', 40000));

connect (con1,localhost,root,,);
begin;
update t2 set f2 = '=';
select f1, right(f2, 20), right(f3, 20) from t2;
update t2 set f3 = '&';
select f1, right(f2, 20), right(f3, 20) from t2;

if ($have_debug_sync) {
--disable_query_log
set DEBUG_SYNC='blob_rollback_middle SIGNAL stuck WAIT_FOR ever';
send ROLLBACK;
--enable_query_log
}

connection default;
if ($have_debug_sync) {
--disable_query_log
SET DEBUG_SYNC = 'now WAIT_FOR stuck';
--enable_query_log
}
SET GLOBAL innodb_flush_log_at_trx_commit=1;
DELETE FROM t1 WHERE a=1;

let $shutdown_timeout=0;
--source include/restart_mysqld.inc

disconnect con1;

select f1, right(f2, 20), right(f3, 20) from t2;
check table t2;
drop table t2;

# ..........................................................................

--echo #
--echo # Compressed Table - Insert Operation - Crash Test
--echo # fresh insert with BLOBs
--echo #

set global innodb_compression_level = 0;

create table t3 (f1 bigint primary key, f2 longblob, f3 longblob,
  index(f2(10), f3(10))) engine=innodb row_format=compressed;

# The BLOB insert will fail, and should disappear. However no data committed
# up to this point should be lost.
connect (con1,localhost,root,,);
begin;
INSERT INTO t3 (f1, f2, f3) VALUES (6, repeat('/', 40000), repeat('<', 40000));

connection default;
SET GLOBAL innodb_flush_log_at_trx_commit=1;
DELETE FROM t1 WHERE a=2;

let $shutdown_timeout=0;
--source include/restart_mysqld.inc

disconnect con1;

select f1, length(f2), length(f3) from t3;
select f1, right(f2, 30), right(f3, 20) from t3;
check table t3;

# ..........................................................................

--echo #
--echo # Compressed Table - Update Operation - Crash Test
--echo # update of a non-BLOB column so that BLOB is needed
--echo #

set global innodb_compression_level = 0;
insert into t3 values (2, repeat('!', 30), repeat('+', 30));

# The BLOB update will fail, and should disappear. However no data committed
# up to this point should be lost.
connect (con1,localhost,root,,);
begin;
UPDATE t3 set f2 = repeat('>', 40000) where f1 = 2;

connection default;
SET GLOBAL innodb_flush_log_at_trx_commit=1;
DELETE FROM t1 WHERE a=3;

let $shutdown_timeout=0;
--source include/restart_mysqld.inc

disconnect con1;

select f1, length(f2), length(f3) from t3;
select f1, right(f2, 30), right(f3, 20) from t3;
check table t3;

# ..........................................................................

--echo #
--echo # Compressed Table - Update Operation - Crash Test
--echo # update blob to blob
--echo #

set global innodb_compression_level = 0;
insert into t3 values (3, repeat('%', 40000), repeat('~', 40000));

# The BLOB update will fail, and should disappear. However no data committed
# up to this point should be lost.
connect (con1,localhost,root,,);
begin;
UPDATE t3 set f2 = concat(f2, repeat(',', 10)) where f1 = 3;

connection default;
SET GLOBAL innodb_flush_log_at_trx_commit=1;
DELETE FROM t1 WHERE a=4;

let $shutdown_timeout=0;
--source include/restart_mysqld.inc

select f1, length(f2), length(f3) from t3;
select f1, right(f2, 30), right(f3, 20) from t3;
check table t3;

DROP TABLE t1,t3;