Skip to content

Commit 4b86ca7

Browse files
author
Tor Didriksen
committed
Bug #11747102 30771: LOG MORE INFO ABOUT THREADS KILL'D AND SORT ABORTED MESSAGES
1 parent 2c9f4a2 commit 4b86ca7

File tree

3 files changed

+58
-2
lines changed

3 files changed

+58
-2
lines changed

mysql-test/r/filesort_debug.result

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,20 @@ DELETE FROM t1 ORDER BY (f1(10)) LIMIT 1;
1414
ERROR 42000: Incorrect number of arguments for FUNCTION test.f1; expected 0, got 1
1515
DROP TABLE t1;
1616
DROP FUNCTION f1;
17+
#
18+
# Bug #11747102
19+
# 30771: LOG MORE INFO ABOUT THREADS KILL'D AND SORT ABORTED MESSAGES
20+
#
21+
# connection 1
22+
CREATE TABLE t1(f0 int auto_increment primary key, f1 int);
23+
INSERT INTO t1(f1) VALUES (0),(1),(2),(3),(4),(5);
24+
SET DEBUG_SYNC='filesort_start SIGNAL filesort_started WAIT_FOR filesort_killed';
25+
# Sending: (not reaped since connection is killed later)
26+
SELECT * FROM t1 ORDER BY f1 ASC, f0;
27+
# connection 2
28+
SET DEBUG_SYNC='now WAIT_FOR filesort_started';
29+
KILL @id;
30+
SET DEBUG_SYNC='now SIGNAL filesort_killed';
31+
# connection default
32+
SET DEBUG_SYNC= "RESET";
33+
DROP TABLE t1;

mysql-test/t/filesort_debug.test

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
--source include/have_debug.inc
2+
--source include/have_debug_sync.inc
3+
--source include/count_sessions.inc
24

35
SET @old_debug= @@session.debug;
46

@@ -21,3 +23,37 @@ DELETE FROM t1 ORDER BY (f1(10)) LIMIT 1;
2123

2224
DROP TABLE t1;
2325
DROP FUNCTION f1;
26+
27+
--echo #
28+
--echo # Bug #11747102
29+
--echo # 30771: LOG MORE INFO ABOUT THREADS KILL'D AND SORT ABORTED MESSAGES
30+
--echo #
31+
32+
connect (con1, localhost, root);
33+
connect (con2, localhost, root);
34+
35+
--echo # connection 1
36+
connection con1;
37+
CREATE TABLE t1(f0 int auto_increment primary key, f1 int);
38+
INSERT INTO t1(f1) VALUES (0),(1),(2),(3),(4),(5);
39+
40+
let $ID= `SELECT @id := CONNECTION_ID()`;
41+
42+
SET DEBUG_SYNC='filesort_start SIGNAL filesort_started WAIT_FOR filesort_killed';
43+
--echo # Sending: (not reaped since connection is killed later)
44+
--send SELECT * FROM t1 ORDER BY f1 ASC, f0
45+
46+
--echo # connection 2
47+
connection con2;
48+
let $ignore= `SELECT @id := $ID`;
49+
SET DEBUG_SYNC='now WAIT_FOR filesort_started';
50+
KILL @id;
51+
SET DEBUG_SYNC='now SIGNAL filesort_killed';
52+
53+
--echo # connection default
54+
connection default;
55+
disconnect con1;
56+
disconnect con2;
57+
--source include/wait_until_count_sessions.inc
58+
SET DEBUG_SYNC= "RESET";
59+
DROP TABLE t1;

sql/filesort.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "probes_mysql.h"
3333
#include "sql_test.h" // TEST_filesort
3434
#include "opt_range.h" // SQL_SELECT
35+
#include "debug_sync.h"
3536

3637
/// How to write record_ref.
3738
#define WRITE_REF(file,from) \
@@ -123,6 +124,7 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
123124
Item_subselect *subselect= tab ? tab->containing_subselect() : 0;
124125

125126
MYSQL_FILESORT_START(table->s->db.str, table->s->table_name.str);
127+
DEBUG_SYNC(thd, "filesort_start");
126128

127129
/*
128130
Release InnoDB's adaptive hash index latch (if holding) before
@@ -325,12 +327,13 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
325327
}
326328
if (error)
327329
{
328-
DBUG_ASSERT(thd->is_error());
330+
int kill_errno= thd->killed_errno();
331+
DBUG_ASSERT(thd->is_error() || kill_errno);
329332
my_printf_error(ER_FILSORT_ABORT,
330333
"%s: %s",
331334
MYF(ME_ERROR + ME_WAITTANG),
332335
ER_THD(thd, ER_FILSORT_ABORT),
333-
thd->stmt_da->message());
336+
kill_errno ? ER(kill_errno) : thd->stmt_da->message());
334337

335338
if (global_system_variables.log_warnings > 1)
336339
{

0 commit comments

Comments
 (0)