Skip to content

Commit

Permalink
Fixed a candidate bug in the MySQL query cancellation
Browse files Browse the repository at this point in the history
Also, added a logging statement on failures to do so.
  • Loading branch information
iagaponenko committed Jul 21, 2023
1 parent 951c35d commit 044b146
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/mysql/MySqlConnection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ bool MySqlConnection::queryUnbuffered(std::string const& query) {
int MySqlConnection::cancel() {
std::lock_guard<std::mutex> lock(_interruptMutex);
int rc;
if (!_isExecuting || _interrupted) {
if (_interrupted) {
// Should we log this?
return -1; // No further action needed.
}
Expand All @@ -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;
Expand Down

0 comments on commit 044b146

Please sign in to comment.