Skip to content

Commit 7d1467e

Browse files
montywivuvova
authored andcommitted
MDEV-34054 Memory leak in Window_func_runner::exec after encountering "temporary space limit reached" error
1 parent 178ab56 commit 7d1467e

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

mysql-test/main/tmp_space_usage.result

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,4 +192,11 @@ DROP TABLE t1;
192192
connection default;
193193
disconnect c1;
194194
set @@global.max_tmp_total_space_usage=@save_max_tmp_total_space_usage;
195+
#
196+
# MDEV-34054
197+
# Memory leak in Window_func_runner::exec after encountering
198+
# "temporary space limit reached" error
199+
SET max_tmp_session_space_usage= 64*1024;
200+
SELECT MIN(VARIABLE_VALUE) OVER (), NTILE(1) OVER (), MAX(VARIABLE_NAME) OVER () FROM information_schema.SESSION_STATUS;
201+
ERROR HY000: Local temporary space limit reached
195202
# End of 11.5 tests

mysql-test/main/tmp_space_usage.test

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,4 +250,13 @@ connection default;
250250
disconnect c1;
251251
set @@global.max_tmp_total_space_usage=@save_max_tmp_total_space_usage;
252252

253+
--echo #
254+
--echo # MDEV-34054
255+
--echo # Memory leak in Window_func_runner::exec after encountering
256+
--echo # "temporary space limit reached" error
257+
258+
SET max_tmp_session_space_usage= 64*1024;
259+
--error 200
260+
SELECT MIN(VARIABLE_VALUE) OVER (), NTILE(1) OVER (), MAX(VARIABLE_NAME) OVER () FROM information_schema.SESSION_STATUS;
261+
253262
--echo # End of 11.5 tests

sql/sql_window.cc

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2859,6 +2859,7 @@ bool compute_window_func(THD *thd,
28592859
{
28602860
List_iterator_fast<Item_window_func> iter_win_funcs(window_functions);
28612861
List_iterator_fast<Cursor_manager> iter_cursor_managers(cursor_managers);
2862+
bool ret= false;
28622863
uint err;
28632864

28642865
READ_RECORD info;
@@ -2921,27 +2922,35 @@ bool compute_window_func(THD *thd,
29212922
/* Check if we found any error in the window function while adding values
29222923
through cursors. */
29232924
if (unlikely(thd->is_error() || thd->is_killed()))
2925+
{
2926+
ret= true;
29242927
break;
2928+
}
29252929

29262930
/* Return to current row after notifying cursors for each window
29272931
function. */
29282932
if (tbl->file->ha_rnd_pos(tbl->record[0], rowid_buf))
2929-
return true;
2933+
{
2934+
ret= true;
2935+
break;
2936+
}
29302937
}
29312938

29322939
/* We now have computed values for each window function. They can now
29332940
be saved in the current row. */
29342941
if (save_window_function_values(window_functions, tbl, rowid_buf))
2935-
return true;
2936-
2942+
{
2943+
ret= true;
2944+
break;
2945+
}
29372946
rownum++;
29382947
}
29392948

29402949
my_free(rowid_buf);
29412950
partition_trackers.delete_elements();
29422951
end_read_record(&info);
29432952

2944-
return false;
2953+
return ret;
29452954
}
29462955

29472956
/* Make a list that is a concation of two lists of ORDER elements */

0 commit comments

Comments
 (0)