diff options
author | Vladislav Vaintroub <wlad@mariadb.com> | 2018-05-19 17:04:47 +0000 |
---|---|---|
committer | Vladislav Vaintroub <wlad@mariadb.com> | 2018-05-19 17:04:47 +0000 |
commit | 207e5ba3167f4d5d4d2e522ed7e2231204f4420f (patch) | |
tree | 69e986ca299a6a33e113f5558fa0d91da2774aac /extra | |
parent | dd51082eca82fe7b61ee2e62f75b84c39f180450 (diff) | |
download | mariadb-git-207e5ba3167f4d5d4d2e522ed7e2231204f4420f.tar.gz |
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.
Diffstat (limited to 'extra')
-rw-r--r-- | extra/mariabackup/backup_mysql.cc | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/extra/mariabackup/backup_mysql.cc b/extra/mariabackup/backup_mysql.cc index 3cfbf5c20fc..d287dcf181d 100644 --- a/extra/mariabackup/backup_mysql.cc +++ b/extra/mariabackup/backup_mysql.cc @@ -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); + } } } |