Skip to content

Commit

Permalink
my_myql: Handle deadlocks in mysql_stmt_execute
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
donald committed Aug 27, 2024
1 parent 41ef7fd commit cab3fe9
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions mx_mysql.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down

0 comments on commit cab3fe9

Please sign in to comment.