diff --git a/mysql-test/main/tmp_space_usage.result b/mysql-test/main/tmp_space_usage.result index 10104062eef..5d3d9a8a9e3 100644 --- a/mysql-test/main/tmp_space_usage.result +++ b/mysql-test/main/tmp_space_usage.result @@ -94,9 +94,6 @@ drop table t1,t2; SET @@max_tmp_session_space_usage= 64*1024; set @@binlog_format="statement"; CREATE OR REPLACE TABLE t1 (a INT, b INT); -select benchmark(1,1); -benchmark(1,1) -0 INSERT INTO t1 SELECT seq, seq FROM seq_1_to_100000; ALTER TABLE t1 ORDER BY a, b; ERROR HY000: Local temporary space limit reached @@ -161,6 +158,7 @@ ERROR HY000: Global temporary space limit reached # MDEV-33751 Assertion `thd' failed in int # temp_file_size_cb_func(tmp_file_tracking*, int) # +set @save_max_tmp_total_space_usage=@@global.max_tmp_total_space_usage; set @@global.max_tmp_total_space_usage=64*1024*1024; set @@max_tmp_session_space_usage=1179648; select @@max_tmp_session_space_usage; @@ -177,4 +175,21 @@ ERROR HY000: Local temporary space limit reached 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; +# +# MDEV-34016 Assertion `info->key_del_used == 0' failed in maria_close +# with limited tmp space +# +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; +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; +SELECT DISTINCT a, seq FROM t1 JOIN seq_1_to_600; +ERROR HY000: Got error 200 "Local temporary space limit reached" when merging index +DROP TABLE t1; +connection default; +disconnect c1; +set @@global.max_tmp_total_space_usage=@save_max_tmp_total_space_usage; # End of 11.5 tests diff --git a/mysql-test/main/tmp_space_usage.test b/mysql-test/main/tmp_space_usage.test index 390018a10d3..a9060c6897d 100644 --- a/mysql-test/main/tmp_space_usage.test +++ b/mysql-test/main/tmp_space_usage.test @@ -142,7 +142,6 @@ SET @@max_tmp_session_space_usage= 64*1024; set @@binlog_format="statement"; CREATE OR REPLACE TABLE t1 (a INT, b INT); -select benchmark(1,1); INSERT INTO t1 SELECT seq, seq FROM seq_1_to_100000; --error 41 ALTER TABLE t1 ORDER BY a, b; @@ -214,7 +213,8 @@ select count(distinct concat(seq,repeat('x',1000))) from seq_1_to_1000; --echo # temp_file_size_cb_func(tmp_file_tracking*, int) --echo # -set @@global.max_tmp_session_space_usage=64*1024*1024; +set @save_max_tmp_total_space_usage=@@global.max_tmp_total_space_usage; +set @@global.max_tmp_total_space_usage=64*1024*1024; set @@max_tmp_session_space_usage=1179648; select @@max_tmp_session_space_usage; set @save_aria_repair_threads=@@aria_repair_threads; @@ -230,5 +230,24 @@ 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; +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 # End of 11.5 tests diff --git a/storage/maria/ma_page.c b/storage/maria/ma_page.c index 0877c966d1c..a3ee3b5eb3e 100644 --- a/storage/maria/ma_page.c +++ b/storage/maria/ma_page.c @@ -393,7 +393,7 @@ int _ma_dispose(register MARIA_HA *info, my_off_t pos, my_bool page_not_read) single _ma_log_new()) call). @return - HA_OFFSET_ERROR File is full or page read error + HA_OFFSET_ERROR File is full or page read error or tmp space full # Page address to use */ @@ -414,6 +414,7 @@ my_off_t _ma_new(register MARIA_HA *info, int level, { my_errno=HA_ERR_INDEX_FILE_FULL; mysql_mutex_unlock(&share->intern_lock); + _ma_unlock_key_del(info); DBUG_RETURN(HA_OFFSET_ERROR); } share->state.state.key_file_length+= block_size; @@ -422,6 +423,7 @@ my_off_t _ma_new(register MARIA_HA *info, int level, share->state.state.key_file_length)) { mysql_mutex_unlock(&share->intern_lock); + _ma_unlock_key_del(info); DBUG_RETURN(HA_OFFSET_ERROR); } /* Following is for not transactional tables */ diff --git a/storage/maria/ma_sort.c b/storage/maria/ma_sort.c index 8f057e85f90..4b24b994ffb 100644 --- a/storage/maria/ma_sort.c +++ b/storage/maria/ma_sort.c @@ -281,7 +281,12 @@ int _ma_create_index_by_sort(MARIA_SORT_PARAM *info, my_bool no_messages, printf(" - Last merge and dumping keys\n"); /* purecov: tested */ if (merge_index(info,keys,sort_keys,dynamic_element(&buffpek,0,BUFFPEK *), maxbuffer,&tempfile)) + { + const char *format= "Got error %M when merging index"; + _ma_check_print_error(info->sort_info->param, + format, (int) my_errno); goto err; /* purecov: inspected */ + } } if (flush_maria_ft_buf(info) || _ma_flush_pending_blocks(info))