Commit 207e5ba3 authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

mariabackup : Fix race condition when killing query waiting for MDL

Itcan happen that the connection is already gone during the window
between quering I_S.PROCESSLIST and KILL QUERY.

Fix is to tolerate ER_NO_SUCH_THREAD returned from KILL QUERY.

Add small improvement in message "Killing MDL query " to actually output
the query.
Also do not try to kill queries that are already in Killed state.
parent dd51082e
......@@ -897,16 +897,23 @@ DECLARE_THREAD(kill_mdl_waiters_thread(void *))
break;
MYSQL_RES *result = xb_mysql_query(mysql,
"SELECT ID, COMMAND FROM INFORMATION_SCHEMA.PROCESSLIST "
"SELECT ID, COMMAND, INFO FROM INFORMATION_SCHEMA.PROCESSLIST "
" WHERE State='Waiting for table metadata lock'",
true, true);
while (MYSQL_ROW row = mysql_fetch_row(result))
{
char query[64];
msg_ts("Killing MDL waiting query '%s' on connection '%s'\n",
row[1], row[0]);
if (row[1] && !strcmp(row[1], "Killed"))
continue;
msg_ts("Killing MDL waiting %s ('%s') on connection %s\n",
row[1], row[2], row[0]);
snprintf(query, sizeof(query), "KILL QUERY %s", row[0]);
xb_mysql_query(mysql, query, true);
if (mysql_query(mysql, query) && (mysql_errno(mysql) != ER_NO_SUCH_THREAD)) {
msg("Error: failed to execute query %s: %s\n", query,mysql_error(mysql));
exit(EXIT_FAILURE);
}
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment