File: tmp_space_usage.test

package info (click to toggle)
mariadb 1%3A11.8.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 772,520 kB
  • sloc: ansic: 2,414,714; cpp: 1,791,394; asm: 381,336; perl: 62,905; sh: 49,647; pascal: 40,897; java: 39,363; python: 20,791; yacc: 20,432; sql: 17,907; xml: 12,344; ruby: 8,544; cs: 6,542; makefile: 6,145; ada: 1,879; lex: 1,193; javascript: 996; objc: 80; tcl: 73; awk: 46; php: 22
file content (308 lines) | stat: -rw-r--r-- 10,839 bytes parent folder | download | duplicates (2)
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
--source include/have_sequence.inc
--source include/have_innodb.inc
--source include/big_test.inc
--source include/not_valgrind.inc
--source include/have_log_bin.inc

call mtr.add_suppression("Write to binary log failed: .* temporary space limit reached. An incident event is written to binary log.*");

#
# Test tmp_space_usage
#

# flush global status is needed because of max_tmp_space_used
flush status;
flush global status;
show session status like "max_tmp_space_used";
show global status like  "max_tmp_space_used";

--echo #
--echo # MDEV-9101 Limit size of total size of created disk temporary files
--echo #           and tables.

# Print variables that can affect the test result
show session status like "tmp_space_used";
show global status like "tmp_space_used";
select @@global.max_tmp_session_space_usage, @@global.max_tmp_total_space_usage;
select @@binlog_stmt_cache_size,@@binlog_format;

create table t1 (a int primary key, v varchar(256), c int default(0)) engine=innodb;
--error 41
insert into t1 (a,v) select seq, repeat(char(64+mod(seq,32)),mod(seq,254)+1) from seq_1_to_65536;
set @@max_tmp_session_space_usage=1024*1024*1024;
--error 42
insert into t1 (a,v) select seq, repeat(char(64+mod(seq,32)),mod(seq,254)+1) from seq_1_to_65536;
set @@max_tmp_session_space_usage=default;

set @@binlog_format="statement";
insert into t1 (a,v) select seq, repeat(char(64+mod(seq,32)),mod(seq,254)+1) from seq_1_to_65536;
insert into t1 (a,v) select seq, repeat(char(64+mod(seq,32)),mod(seq,254)+1) from seq_65537_to_131072;
select count(*) from t1;

create table t2 (a int, b int) engine=innodb select seq as a, 0 as b from seq_1_to_131072;

# Force usage of on disk tmp tables
set @@binlog_format="row";
set @@tmp_memory_table_size=32*1024;

--echo # The following queries should fail because of tmp_space_usage
--error 41
select * from t1 order by a,v;
--error HA_ERR_LOCAL_TMP_SPACE_FULL
select v,count(*) from t1 group by v limit 2;
--error 41
update t1 set v=right(v,2);

set @@binlog_format="statement";
set @@max_tmp_session_space_usage=65536;
set @@tmp_memory_table_size=0;
--error HA_ERR_LOCAL_TMP_SPACE_FULL
update t1,t2 set t1.c=t2.a, t2.b=1 where t1.a=t2.a;
set @@binlog_format="row";
set @@max_tmp_session_space_usage=default;

drop table t1,t2;

--echo #
--echo # Check max_tmp_total_space_usage & processlist
--echo #

# We have to set tmp_memory_table_size to ensure we do not use disk for
# the following two show commands.
set @@tmp_memory_table_size=1024*1024;
show session status like "tmp_space_used";
# The following is disabled until we can do "show status" without using
# temporary files
# show global status like "tmp_space_used";
set @@tmp_memory_table_size=0;

let $tmp_usage1=`select variable_value from information_schema.session_status where variable_name="max_tmp_space_used"`;
flush status;
let $tmp_usage2=`select variable_value from information_schema.global_status where variable_name="max_tmp_space_used"`;

--disable_query_log
if ($tmp_usage1 == $tmp_usage2)
{
--echo # session.max_tmp_session_space_usage == global.max_tmp_session_space_usage
}
if ($tmp_usage1 != $tmp_usage2)
{
--echo session.max_tmp_session_space_usage ($tmp_usage1) != global.max_tmp_session_space_usage ($tmp_usage2)
}
--enable_query_log


connect(c1, localhost, root,,);
connection default;

create table t1 (a int primary key, v varchar(256), c int default(0)) engine=innodb;
create table t2 (a int primary key, v varchar(256), c int default(0)) engine=innodb;

begin;
insert into t1 (a,v) select seq, repeat(char(64+mod(seq,32)),mod(seq,254)+1) from seq_1_to_3000;

let $id=`select connection_id()`;
let $tmp_usage1=`select variable_value from information_schema.session_status where variable_name="tmp_space_used"`;

connection c1;
--disable_query_log
let $tmp_usage2=`select tmp_space_used from information_schema.processlist where id=$id`;
if ($tmp_usage1 == $tmp_usage2)
{
--echo # information_schema.process_list.tmp_space_used == status.tmp_space_used
}
if ($tmp_usage1 != $tmp_usage2)
{
--echo tmp_space_used difference: $tmp_usage1 != $tmp_usage2
}
--enable_query_log

--error 42
insert into t2 (a,v) select seq, repeat(char(64+mod(seq,32)),mod(seq,254)+1) from seq_1_to_3000;
--echo # Test setting tmp_space_usage to 0 to disable quotas
set @save_max_tmp_total_space_usage=@@global.max_tmp_total_space_usage;
set @@global.max_tmp_total_space_usage=0;
set @@max_tmp_session_space_usage=0;
insert into t2 (a,v) select seq, repeat(char(64+mod(seq,32)),mod(seq,254)+1) from seq_1_to_3000;
set @@global.max_tmp_total_space_usage=@save_max_tmp_total_space_usage;
set @@max_tmp_session_space_usage=0;
connection default;
insert into t1 (a,v) values(9999990,0);
commit;
select count(*) from t1;

disconnect c1;
drop table t1,t2;

--echo #
--echo # Test case from Elena
--echo #

SET @@max_tmp_session_space_usage= 64*1024;
set @@binlog_format="statement";

CREATE OR REPLACE TABLE t1 (a INT, b INT);
INSERT INTO t1 SELECT seq, seq FROM seq_1_to_100000;
--error 41
ALTER TABLE t1 ORDER BY a, b;

# Cleanup
DROP TABLE t1;

--echo #
--echo # Show that setting max tmp space too low value can stop binary logging
--echo # if non transactional tables are used.
--echo #

set @save_max_tmp_total_space_usage=@@global.max_tmp_total_space_usage;
SET @@global.max_tmp_total_space_usage=64*1024;
set @@binlog_format="row";

create table t1 (a int primary key, v varchar(256)) engine=myisam;
--error 41,42
insert into t1 (a,v) select seq, repeat(char(64+mod(seq,32)),mod(seq,254)+1) from seq_1_to_65536;
show warnings;
select count(*) <> 0 from t1;

# Shhow that this problem does not exists with transactional tables
truncate table t1;
alter table t1 engine=innodb;
--error 41,42
insert into t1 (a,v) select seq, repeat(char(64+mod(seq,32)),mod(seq,254)+1) from seq_1_to_65536;
show warnings;
select count(*) <> 0 from t1;
drop table t1;

set @@global.max_tmp_total_space_usage=@save_max_tmp_total_space_usage;

--echo #
--echo # Check updating non transactional table
--echo #

SET max_tmp_session_space_usage= 64*1024;
 
CREATE TABLE t1 (
  a varchar(1024), b varchar(1024), c varchar(1024), d varchar(1024), e varchar(1024), f varchar(1024), g varchar(1024)
) ENGINE=MyISAM;
 
INSERT INTO t1 VALUES
(REPEAT('x',1024),REPEAT('x',1024),REPEAT('x',1024),REPEAT('x',1024),REPEAT('x',1024),REPEAT('x',1024),REPEAT('x',1024)),
(REPEAT('x',1024),REPEAT('x',1024),REPEAT('x',1024),REPEAT('x',1024),REPEAT('x',1024),REPEAT('x',1024),REPEAT('x',1024)),
(REPEAT('x',1024),REPEAT('x',1024),REPEAT('x',1024),REPEAT('x',1024),REPEAT('x',1024),REPEAT('x',1024),REPEAT('x',1024)),
(REPEAT('x',1024),REPEAT('x',1024),REPEAT('x',1024),REPEAT('x',1024),REPEAT('x',1024),REPEAT('x',1024),REPEAT('x',1024)),
(REPEAT('x',1024),REPEAT('x',1024),REPEAT('x',1024),REPEAT('x',1024),REPEAT('x',1024),REPEAT('x',1024),REPEAT('x',1024)),
(REPEAT('x',1024),REPEAT('x',1024),REPEAT('x',1024),REPEAT('x',1024),REPEAT('x',1024),REPEAT('x',1024),REPEAT('x',1024)),
('x','x','x','x','x','x','x');
 
--error 41
UPDATE t1 SET a = '' LIMIT 100;

DROP TABLE t1;

--echo #
--echo # MDEV-33680 Server hangs or assertion fails upon SELECT with limited
--echo # max_tmp_space_usage
--echo #

set max_tmp_session_space_usage = 1024*1024;
--error HA_ERR_GLOBAL_TMP_SPACE_FULL
select count(distinct concat(seq,repeat('x',1000))) from seq_1_to_1000;

--echo #
--echo # MDEV-33751 Assertion `thd' failed in int
--echo # temp_file_size_cb_func(tmp_file_tracking*, int)
--echo #

set @save_max_tmp_total_space_usage=@@global.max_tmp_total_space_usage;
set @@global.max_tmp_total_space_usage=64*1024*1024;
# Binlog cache reserve 4096 bytes at the begin of the temporary file.
set @@max_tmp_session_space_usage=1179648+65536;
select @@max_tmp_session_space_usage;
set @save_aria_repair_threads=@@aria_repair_threads;
set @@aria_repair_threads=2;
set @save_max_heap_table_size=@@max_heap_table_size;
set @@max_heap_table_size=16777216;

CREATE TABLE t1 (a CHAR(255),b INT,INDEX (b));
INSERT INTO t1 SELECT SEQ,SEQ FROM seq_1_to_100000;
set @@max_tmp_session_space_usage=1179648;
--error HA_ERR_LOCAL_TMP_SPACE_FULL
SELECT * FROM t1 UNION SELECT * FROM t1;
DROP TABLE t1;

set @@aria_repair_threads=@save_aria_repair_threads;
set @@max_heap_table_size=@save_max_heap_table_size;
set @@global.max_tmp_total_space_usage=@save_max_tmp_total_space_usage;

--echo #
--echo # MDEV-34016 Assertion `info->key_del_used == 0' failed in maria_close
--echo # with limited tmp space
--echo #

set @save_max_tmp_total_space_usage=@@global.max_tmp_total_space_usage;
connect(c1, localhost, root,,);
CREATE TABLE t1 (a varchar(1024)) engine=aria CHARSET=latin1;
INSERT INTO t1 VALUES ('this'),('is'),('just'),('a'),('filling'),('for'),(REPEAT('a',500));
set @@global.max_tmp_total_space_usage=2*1024*1024;
SET max_tmp_session_space_usage= 1024*1024, max_heap_table_size= 4*1024*1024;
--error ER_NOT_KEYFILE
SELECT DISTINCT a, seq FROM t1 JOIN seq_1_to_600;
DROP TABLE t1;
connection default;
disconnect c1;
set @@global.max_tmp_total_space_usage=@save_max_tmp_total_space_usage;

--echo #
--echo # MDEV-34054
--echo # Memory leak in Window_func_runner::exec after encountering
--echo # "temporary space limit reached" error

SET max_tmp_session_space_usage= 64*1024;
--error HA_ERR_LOCAL_TMP_SPACE_FULL
SELECT MIN(VARIABLE_VALUE) OVER (), NTILE(1) OVER (), MAX(VARIABLE_NAME) OVER () FROM information_schema.SESSION_STATUS;

--echo #
--echo # MDEV-34060 Unexpected behavior upon reading I_S.ALL_PLUGINS under
--echo # limited tmp space
--echo #

connect(c1, localhost, root,,);
set @@binlog_format=row;
CREATE OR REPLACE TABLE t1 (a DATETIME) ENGINE=InnoDB;
# Binlog cache file will be truncated at commit, thus keep the the transaction
# to keep binlog cache temporary file large enough
BEGIN;
INSERT INTO t1 SELECT NOW() FROM seq_1_to_6000;

SET max_tmp_session_space_usage = 64*1024;
--error HA_ERR_LOCAL_TMP_SPACE_FULL
SELECT * FROM information_schema.ALL_PLUGINS LIMIT 2;
ROLLBACK;
drop table t1;
connection default;
disconnect c1;

--echo #
--echo # MDEV-34142 Server crashes in create_internal_tmp_table with low tmp
--echo # space limit
--echo #

SET MAX_TMP_SESSION_SPACE_USAGE = 128*1024, MAX_HEAP_TABLE_SIZE= 16*1024*1024;
CREATE TABLE t1 (a varchar(1024)) DEFAULT CHARACTER SET utf8mb3;
INSERT INTO t1 SELECT 'x' FROM seq_1_to_50;
--error HA_ERR_LOCAL_TMP_SPACE_FULL
SELECT * FROM t1 JOIN seq_1_to_200 INTERSECT ALL SELECT * FROM t1 JOIN seq_1_to_200;
drop table t1;

--echo #
--echo # MDEV-34149 Corruption-like errors are produced when temporary space
--echo # limit is reached
--echo #

SET MAX_TMP_SESSION_SPACE_USAGE = 400*1024;
--error HA_ERR_LOCAL_TMP_SPACE_FULL
SELECT VARIABLE_VALUE FROM information_schema.GLOBAL_VARIABLES JOIN seq_1_to_100
INTERSECT ALL
SELECT VARIABLE_VALUE FROM information_schema.GLOBAL_VARIABLES JOIN seq_1_to_100;

--echo # End of 11.5 tests