From 044b146c555409059e2d2e9fe02ac7ed201c13b4 Mon Sep 17 00:00:00 2001 From: Igor Gaponenko Date: Fri, 21 Jul 2023 02:01:41 +0000 Subject: [PATCH] Fixed a candidate bug in the MySQL query cancellation Also, added a logging statement on failures to do so. --- src/mysql/MySqlConnection.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/mysql/MySqlConnection.cc b/src/mysql/MySqlConnection.cc index 48a88858af..f9532242ac 100644 --- a/src/mysql/MySqlConnection.cc +++ b/src/mysql/MySqlConnection.cc @@ -155,7 +155,7 @@ bool MySqlConnection::queryUnbuffered(std::string const& query) { int MySqlConnection::cancel() { std::lock_guard lock(_interruptMutex); int rc; - if (!_isExecuting || _interrupted) { + if (_interrupted) { // Should we log this? return -1; // No further action needed. } @@ -172,6 +172,9 @@ int MySqlConnection::cancel() { rc = mysql_real_query(killMysql, killSql.c_str(), killSql.size()); mysql_close(killMysql); if (rc) { + LOGS(_log, LOG_LVL_WARN, + "failed to kill MySQL thread: " << threadId << ", error: " << std::string(mysql_error(killMysql)) + << ", errno: " << std::to_string(mysql_errno(killMysql))); return 2; } return 0;