From a7f84f09bfec22e26b3bd54505a9c8e1d0faff40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 31 Jul 2018 16:12:38 +0300 Subject: MDEV-16865 InnoDB fts_query() ignores KILL The functions fts_ast_visit() and fts_query() inside InnoDB FULLTEXT INDEX query processing are not checking for THD::killed (trx_is_interrupted()), like anything that potentially takes a long time should do. This is a port of the following change from MySQL 5.7.23, with a completely rewritten test case. commit c58c6f8f66ddd0357ecd0c99646aa6bf1dae49c8 Author: Aakanksha Verma Date: Fri May 4 15:53:13 2018 +0530 Bug #27155294 MAX_EXECUTION_TIME NOT INTERUPTED WITH FULLTEXT SEARCH USING MECAB --- storage/innobase/fts/fts0que.cc | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'storage/innobase/fts/fts0que.cc') diff --git a/storage/innobase/fts/fts0que.cc b/storage/innobase/fts/fts0que.cc index 3a543836837..7d4cd7a3646 100644 --- a/storage/innobase/fts/fts0que.cc +++ b/storage/innobase/fts/fts0que.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2007, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2007, 2018, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2017, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under @@ -3970,6 +3970,7 @@ fts_query( /* Parse the input query string. */ if (fts_query_parse(&query, lc_query_str, result_len)) { fts_ast_node_t* ast = query.root; + ast->trx = trx; /* Optimize query to check if it's a single term */ fts_query_can_optimize(&query, flags); @@ -3983,6 +3984,11 @@ fts_query( query.error = fts_ast_visit( FTS_NONE, ast, fts_query_visitor, &query, &will_be_ignored); + if (query.error == DB_INTERRUPTED) { + error = DB_INTERRUPTED; + ut_free(lc_query_str); + goto func_exit; + } /* If query expansion is requested, extend the search with first search pass result */ @@ -4010,6 +4016,15 @@ fts_query( memset(*result, 0, sizeof(**result)); } + if (trx_is_interrupted(trx)) { + error = DB_INTERRUPTED; + ut_free(lc_query_str); + if (result != NULL) { + fts_query_free_result(*result); + } + goto func_exit; + } + ut_free(lc_query_str); if (fts_enable_diag_print && (*result)) { -- cgit v1.2.1 From b963cbaf4bcfe2c510c38edeacc2d6b1cae2d7a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 3 Aug 2018 11:49:49 +0300 Subject: Follow-up fix to MDEV-16865: InnoDB fts_query() ignores KILL fts_query(): Remove a redundant condition (result will never be NULL), and instead check if *result is NULL, to prevent SIGSEGV in fts_query_free_result(). --- storage/innobase/fts/fts0que.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'storage/innobase/fts/fts0que.cc') diff --git a/storage/innobase/fts/fts0que.cc b/storage/innobase/fts/fts0que.cc index 7d4cd7a3646..78521df75d9 100644 --- a/storage/innobase/fts/fts0que.cc +++ b/storage/innobase/fts/fts0que.cc @@ -4019,7 +4019,7 @@ fts_query( if (trx_is_interrupted(trx)) { error = DB_INTERRUPTED; ut_free(lc_query_str); - if (result != NULL) { + if (*result) { fts_query_free_result(*result); } goto func_exit; -- cgit v1.2.1