mirror of
https://github.com/MariaDB/server.git
synced 2026-04-26 18:25:30 +02:00
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.
This commit is contained in:
parent
dd51082eca
commit
207e5ba316
1 changed files with 11 additions and 4 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue