diff options
author | Jan Lindström <jan.lindstrom@mariadb.com> | 2019-10-29 13:11:34 +0200 |
---|---|---|
committer | Jan Lindström <jan.lindstrom@mariadb.com> | 2019-10-30 10:14:56 +0200 |
commit | 36a969437845ce9f47a9e6d91514ddc7e00ca83a (patch) | |
tree | 847bffee755a4017242e5ca576b78c5fc3d2018d | |
parent | 44b0c8697135be4139c4431bbf02fbf4433e058f (diff) | |
download | mariadb-git-36a969437845ce9f47a9e6d91514ddc7e00ca83a.tar.gz |
MDEV-18562 [ERROR] InnoDB: WSREP: referenced FK check fail: Lock wait index
Lock wait can happen on secondary index when doing FK checks for wsrep.
We should just return error to upper layer and applier will retry
operation when needed.
-rw-r--r-- | include/mysql/service_wsrep.h | 4 | ||||
-rw-r--r-- | sql/wsrep_dummy.cc | 4 | ||||
-rw-r--r-- | sql/wsrep_mysqld.cc | 48 | ||||
-rw-r--r-- | storage/innobase/row/row0upd.cc | 14 |
4 files changed, 40 insertions, 30 deletions
diff --git a/include/mysql/service_wsrep.h b/include/mysql/service_wsrep.h index 3b01d983c06..923ba57fcdc 100644 --- a/include/mysql/service_wsrep.h +++ b/include/mysql/service_wsrep.h @@ -99,7 +99,7 @@ extern struct wsrep_service_st { enum wsrep_conflict_state (*wsrep_thd_get_conflict_state_func)(MYSQL_THD); my_bool (*wsrep_thd_is_BF_func)(MYSQL_THD , my_bool); my_bool (*wsrep_thd_is_wsrep_func)(MYSQL_THD thd); - char * (*wsrep_thd_query_func)(THD *thd); + const char * (*wsrep_thd_query_func)(THD *thd); enum wsrep_query_state (*wsrep_thd_query_state_func)(THD *thd); const char * (*wsrep_thd_query_state_str_func)(THD *thd); int (*wsrep_thd_retry_counter_func)(THD *thd); @@ -182,7 +182,7 @@ extern long wsrep_protocol_version; bool wsrep_consistency_check(THD *thd); bool wsrep_prepare_key(const unsigned char* cache_key, size_t cache_key_len, const unsigned char* row_id, size_t row_id_len, struct wsrep_buf* key, size_t* key_len); -char *wsrep_thd_query(THD *thd); +const char *wsrep_thd_query(THD *thd); const char *wsrep_thd_conflict_state_str(THD *thd); const char *wsrep_thd_exec_mode_str(THD *thd); const char *wsrep_thd_query_state_str(THD *thd); diff --git a/sql/wsrep_dummy.cc b/sql/wsrep_dummy.cc index 2d0a8bcdfa9..b98dd1e5790 100644 --- a/sql/wsrep_dummy.cc +++ b/sql/wsrep_dummy.cc @@ -101,8 +101,8 @@ enum wsrep_conflict_state wsrep_thd_get_conflict_state(THD *) my_bool wsrep_thd_is_wsrep(THD *) { return 0; } -char *wsrep_thd_query(THD *) -{ return 0; } +const char *wsrep_thd_query(THD *) +{ return "NULL"; } enum wsrep_query_state wsrep_thd_query_state(THD *) { return QUERY_IDLE; } diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index 12a9dc35a6a..5e2e48fd15d 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -1594,25 +1594,6 @@ static bool wsrep_can_run_in_toi(THD *thd, const char *db, const char *table, } } -static const char* wsrep_get_query_or_msg(const THD* thd) -{ - switch(thd->lex->sql_command) - { - case SQLCOM_CREATE_USER: - return "CREATE USER"; - case SQLCOM_GRANT: - return "GRANT"; - case SQLCOM_REVOKE: - return "REVOKE"; - case SQLCOM_SET_OPTION: - if (thd->lex->definer) - return "SET PASSWORD"; - /* fallthrough */ - default: - return thd->query(); - } -} - /* returns: 0: statement was replicated as TOI @@ -1636,7 +1617,7 @@ static int wsrep_TOI_begin(THD *thd, char *db_, char *table_, } WSREP_DEBUG("TO BEGIN: %lld, %d : %s", (long long)wsrep_thd_trx_seqno(thd), - thd->wsrep_exec_mode, wsrep_get_query_or_msg(thd)); + thd->wsrep_exec_mode, wsrep_thd_query(thd)); switch (thd->lex->sql_command) { @@ -1716,13 +1697,13 @@ static void wsrep_TOI_end(THD *thd) { wsrep_to_isolation--; WSREP_DEBUG("TO END: %lld, %d: %s", (long long)wsrep_thd_trx_seqno(thd), - thd->wsrep_exec_mode, wsrep_get_query_or_msg(thd)); + thd->wsrep_exec_mode, wsrep_thd_query(thd)); wsrep_set_SE_checkpoint(thd->wsrep_trx_meta.gtid.uuid, thd->wsrep_trx_meta.gtid.seqno); WSREP_DEBUG("TO END: %lld, update seqno", (long long)wsrep_thd_trx_seqno(thd)); - + if (WSREP_OK == (ret = wsrep->to_execute_end(wsrep, thd->thread_id))) { WSREP_DEBUG("TO END: %lld", (long long)wsrep_thd_trx_seqno(thd)); } @@ -2674,9 +2655,28 @@ extern "C" query_id_t wsrep_thd_query_id(THD *thd) } -char *wsrep_thd_query(THD *thd) +const char *wsrep_thd_query(THD *thd) { - return (thd) ? thd->query() : NULL; + if (thd) + { + switch(thd->lex->sql_command) + { + case SQLCOM_CREATE_USER: + return "CREATE USER"; + case SQLCOM_GRANT: + return "GRANT"; + case SQLCOM_REVOKE: + return "REVOKE"; + case SQLCOM_SET_OPTION: + if (thd->lex->definer) + return "SET PASSWORD"; + /* fallthrough */ + default: + if (thd->query()) + return thd->query(); + } + } + return "NULL"; } diff --git a/storage/innobase/row/row0upd.cc b/storage/innobase/row/row0upd.cc index 021e3d69f8a..db4b7b18269 100644 --- a/storage/innobase/row/row0upd.cc +++ b/storage/innobase/row/row0upd.cc @@ -2472,17 +2472,27 @@ row_upd_sec_index_entry( case DB_NO_REFERENCED_ROW: err = DB_SUCCESS; break; + case DB_LOCK_WAIT: + if (wsrep_debug) { + ib::warn() << "WSREP: sec index FK lock wait" + << " index " << index->name + << " table " << index->table->name + << " query " << wsrep_thd_query(trx->mysql_thd); + } + break; case DB_DEADLOCK: if (wsrep_debug) { ib::warn() << "WSREP: sec index FK check fail for deadlock" << " index " << index->name - << " table " << index->table->name; + << " table " << index->table->name + << " query " << wsrep_thd_query(trx->mysql_thd); } break; default: ib::error() << "WSREP: referenced FK check fail: " << ut_strerr(err) << " index " << index->name - << " table " << index->table->name; + << " table " << index->table->name + << " query " << wsrep_thd_query(trx->mysql_thd); break; } |