Skip to content

Commit cfea7c7

Browse files
author
Tor Didriksen
committed
Bug#13832772 ASSERTION `THD->IS_ERROR() || KILL_ERRNO'
We are trying to sort a lot of text/blob fields, so the buffer is indeed too small. Memory available = thd->variables.sortbuff_size = 262144 min_sort_memory = param.sort_length*MERGEBUFF2 = 292245 So the decision to abort the query is correct. filesort() calls my_error(), the error is reported. But, since we have DELETE IGNORE ... the error is converted to a warning by THD::raise_condition filesort currently expects an error to be recorded in the THD diagnostics area. If we lift this restriction (remove the assert) we end up in the familiar void Protocol::end_statement() default: DBUG_ASSERT(0); The solution seems to be to call my_error(ME_FATALERROR) in filesort, so that the error is propagated as an error rather than a warning.
1 parent 7a4e8d9 commit cfea7c7

File tree

3 files changed

+89
-1
lines changed

3 files changed

+89
-1
lines changed

mysql-test/r/filesort_debug.result

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,47 @@ SET DEBUG_SYNC='now SIGNAL filesort_killed';
3131
# connection default
3232
SET DEBUG_SYNC= "RESET";
3333
DROP TABLE t1;
34+
#
35+
# Bug#13832772 ASSERTION `THD->IS_ERROR() || KILL_ERRNO'
36+
# FAILED IN FILESORT/MYSQL_DELETE
37+
#
38+
CREATE TABLE t1 (
39+
c1 BLOB,
40+
c2 TEXT,
41+
c3 TEXT,
42+
c4 TEXT,
43+
c5 TEXT,
44+
c6 TEXT,
45+
c7 TEXT,
46+
c8 BLOB,
47+
c9 TEXT,
48+
c19 TEXT,
49+
pk INT,
50+
c20 TEXT,
51+
c21 BLOB,
52+
c22 TEXT,
53+
c23 TEXT,
54+
c24 TEXT,
55+
c25 TEXT,
56+
c26 BLOB,
57+
c27 TEXT,
58+
c28 TEXT,
59+
primary key (pk)
60+
) ENGINE=InnoDB
61+
;
62+
CALL mtr.add_suppression("Out of sort memory");
63+
DELETE IGNORE FROM t1 ORDER BY c26,c7,c23,c4,c25,c5,c20,
64+
c19,c21,c8,c1,c27,c28,c3,c9,c22,c24,c6,c2,pk LIMIT 2;
65+
ERROR HY001: Out of sort memory, consider increasing server sort buffer size
66+
SHOW WARNINGS;
67+
Level Code Message
68+
Error 1038 Out of sort memory, consider increasing server sort buffer size
69+
Error 1028 Sort aborted: Out of sort memory, consider increasing server sort buffer size
70+
DELETE FROM t1 ORDER BY c26,c7,c23,c4,c25,c5,c20,
71+
c19,c21,c8,c1,c27,c28,c3,c9,c22,c24,c6,c2,pk LIMIT 2;
72+
ERROR HY001: Out of sort memory, consider increasing server sort buffer size
73+
SHOW WARNINGS;
74+
Level Code Message
75+
Error 1038 Out of sort memory, consider increasing server sort buffer size
76+
Error 1028 Sort aborted: Out of sort memory, consider increasing server sort buffer size
77+
DROP TABLE t1;

mysql-test/t/filesort_debug.test

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,47 @@ disconnect con2;
5757
--source include/wait_until_count_sessions.inc
5858
SET DEBUG_SYNC= "RESET";
5959
DROP TABLE t1;
60+
61+
--echo #
62+
--echo # Bug#13832772 ASSERTION `THD->IS_ERROR() || KILL_ERRNO'
63+
--echo # FAILED IN FILESORT/MYSQL_DELETE
64+
--echo #
65+
66+
CREATE TABLE t1 (
67+
c1 BLOB,
68+
c2 TEXT,
69+
c3 TEXT,
70+
c4 TEXT,
71+
c5 TEXT,
72+
c6 TEXT,
73+
c7 TEXT,
74+
c8 BLOB,
75+
c9 TEXT,
76+
c19 TEXT,
77+
pk INT,
78+
c20 TEXT,
79+
c21 BLOB,
80+
c22 TEXT,
81+
c23 TEXT,
82+
c24 TEXT,
83+
c25 TEXT,
84+
c26 BLOB,
85+
c27 TEXT,
86+
c28 TEXT,
87+
primary key (pk)
88+
) ENGINE=InnoDB
89+
;
90+
91+
CALL mtr.add_suppression("Out of sort memory");
92+
93+
--error ER_OUT_OF_SORTMEMORY
94+
DELETE IGNORE FROM t1 ORDER BY c26,c7,c23,c4,c25,c5,c20,
95+
c19,c21,c8,c1,c27,c28,c3,c9,c22,c24,c6,c2,pk LIMIT 2;
96+
SHOW WARNINGS;
97+
98+
--error ER_OUT_OF_SORTMEMORY
99+
DELETE FROM t1 ORDER BY c26,c7,c23,c4,c25,c5,c20,
100+
c19,c21,c8,c1,c27,c28,c3,c9,c22,c24,c6,c2,pk LIMIT 2;
101+
SHOW WARNINGS;
102+
103+
DROP TABLE t1;

sql/filesort.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
235235
sort_keys= table_sort.sort_keys;
236236
if (memavl < min_sort_memory)
237237
{
238-
my_error(ER_OUT_OF_SORTMEMORY,MYF(ME_ERROR+ME_WAITTANG));
238+
my_error(ER_OUT_OF_SORTMEMORY,MYF(ME_ERROR + ME_FATALERROR));
239239
goto err;
240240
}
241241
if (open_cached_file(&buffpek_pointers,mysql_tmpdir,TEMP_PREFIX,

0 commit comments

Comments
 (0)