diff options
author | Jan Lindström <jan.lindstrom@mariadb.com> | 2021-02-16 08:46:14 +0200 |
---|---|---|
committer | Jan Lindström <jan.lindstrom@mariadb.com> | 2021-02-16 08:46:14 +0200 |
commit | a5bcec727b096f634e43f9031440cc1dc9e302c2 (patch) | |
tree | c1005cdf624719b0e97e318b0d11cd5ec81bfc52 /sql/wsrep_mysqld.cc | |
parent | d0defd1ea2af80a360332fd8c1e60a34e2289213 (diff) | |
download | mariadb-git-a5bcec727b096f634e43f9031440cc1dc9e302c2.tar.gz |
MDEV-24865 : Server crashes when truncate mysql user tablebb-10.4-MDEV-24865
For truncate we try to find out possible foreign key tables
using open_tables. However, table_list was not cleaned up
properly and there was no error handling. Fixed by cleaning
table_list and adding proper error handling.
Diffstat (limited to 'sql/wsrep_mysqld.cc')
-rw-r--r-- | sql/wsrep_mysqld.cc | 45 |
1 files changed, 28 insertions, 17 deletions
diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index c0f48cca9cd..5fbed9666c4 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -1184,10 +1184,17 @@ void wsrep_keys_free(wsrep_key_arr_t* key_arr) key_arr->keys_len= 0; } -void +/*! + * @param thd thread + * @param tables list of tables + * @param keys prepared keys + + * @return true if parent table append was successfull, otherwise false. +*/ +bool wsrep_append_fk_parent_table(THD* thd, TABLE_LIST* tables, wsrep::key_array* keys) { - if (!WSREP(thd) || !WSREP_CLIENT(thd)) return; + bool fail= false; TABLE_LIST *table; thd->release_transactional_locks(); @@ -1198,6 +1205,8 @@ wsrep_append_fk_parent_table(THD* thd, TABLE_LIST* tables, wsrep::key_array* key open_tables(thd, &tables, &counter, MYSQL_OPEN_FORCE_SHARED_HIGH_PRIO_MDL)) { WSREP_DEBUG("unable to open table for FK checks for %s", thd->query()); + fail= true; + goto exit; } for (table= tables; table; table= table->next_local) @@ -1219,14 +1228,18 @@ wsrep_append_fk_parent_table(THD* thd, TABLE_LIST* tables, wsrep::key_array* key } } +exit: /* close the table and release MDL locks */ close_thread_tables(thd); thd->mdl_context.rollback_to_savepoint(mdl_savepoint); for (table= tables; table; table= table->next_local) { table->table= NULL; + table->next_global= NULL; table->mdl_request.ticket= NULL; } + + return fail; } /*! @@ -1965,7 +1978,7 @@ static int wsrep_TOI_begin(THD *thd, const char *db, const char *table, { DBUG_ASSERT(thd->variables.wsrep_OSU_method == WSREP_OSU_TOI); - WSREP_DEBUG("TOI Begin"); + WSREP_DEBUG("TOI Begin for %s", WSREP_QUERY(thd)); if (wsrep_can_run_in_toi(thd, db, table, table_list) == false) { WSREP_DEBUG("No TOI for %s", WSREP_QUERY(thd)); @@ -2055,22 +2068,20 @@ static void wsrep_TOI_end(THD *thd) { wsrep_to_isolation--; wsrep::client_state& client_state(thd->wsrep_cs()); DBUG_ASSERT(wsrep_thd_is_local_toi(thd)); - WSREP_DEBUG("TO END: %lld: %s", client_state.toi_meta().seqno().get(), - WSREP_QUERY(thd)); - if (wsrep_thd_is_local_toi(thd)) + wsrep_set_SE_checkpoint(client_state.toi_meta().gtid()); + + int ret= client_state.leave_toi_local(wsrep::mutable_buffer()); + + if (!ret) { - wsrep_set_SE_checkpoint(client_state.toi_meta().gtid()); - int ret= client_state.leave_toi_local(wsrep::mutable_buffer()); - if (!ret) - { - WSREP_DEBUG("TO END: %lld", client_state.toi_meta().seqno().get()); - } - else - { - WSREP_WARN("TO isolation end failed for: %d, schema: %s, sql: %s", - ret, (thd->db.str ? thd->db.str : "(null)"), WSREP_QUERY(thd)); - } + WSREP_DEBUG("TO END: %lld: %s", + client_state.toi_meta().seqno().get(), WSREP_QUERY(thd)); + } + else + { + WSREP_WARN("TO isolation end failed for: %d, sql: %s", + ret, WSREP_QUERY(thd)); } } |