From a4b1099db872d75868caa7f495bb7b57fd78e31f Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Tue, 27 Aug 2024 21:19:41 +0200 Subject: [PATCH 1/2] fixup! mxqkill: Use cancel_group With the new logic, the normal program flow runs until the end of main(). Unfortunately, there is a `return(1);` at the end. Remove that. --- mxqkill.c | 1 - 1 file changed, 1 deletion(-) diff --git a/mxqkill.c b/mxqkill.c index 2615866..6d5f21f 100644 --- a/mxqkill.c +++ b/mxqkill.c @@ -461,5 +461,4 @@ int main(int argc, char *argv[]) mx_mysql_finish(&mysql); mx_log_info("MySQL: Connection to database closed."); - return 1; } From cab3fe9118a077b3b4da903edd0f5c8646150770 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Mon, 26 Aug 2024 16:42:50 +0200 Subject: [PATCH 2/2] my_myql: Handle deadlocks in mysql_stmt_execute We've seen deadlocks when mxqkill races with job completion. Handle deadlocks errors in mysql_stmt_execute. This is possible, because we don't start multi-statement transactions. --- mx_mysql.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/mx_mysql.c b/mx_mysql.c index ca983b0..2894ca7 100644 --- a/mx_mysql.c +++ b/mx_mysql.c @@ -262,14 +262,13 @@ static int mx__mysql_stmt_bind_result(struct mx_mysql_stmt *stmt) static int mx__mysql_stmt_execute(struct mx_mysql_stmt *stmt) { - int res; - assert(stmt); assert(stmt->stmt); - res = mysql_stmt_execute(stmt->stmt); - if (res == 0) - return 0; + do { + if (mysql_stmt_execute(stmt->stmt) == 0) + return 0; + } while (mysql_stmt_errno(stmt->stmt) == ER_LOCK_DEADLOCK); mx_mysql_save_error(mysql_stmt_error(stmt->stmt));