diff --git a/mysql-test/suite/galera/r/galera_mdev_13787.result b/mysql-test/suite/galera/r/galera_mdev_13787.result new file mode 100644 index 00000000000..e3133f60b0c --- /dev/null +++ b/mysql-test/suite/galera/r/galera_mdev_13787.result @@ -0,0 +1,3 @@ +create table t(a int); +insert into t select 1; +DROP TABLE t; diff --git a/mysql-test/suite/galera/t/galera_mdev_13787.opt b/mysql-test/suite/galera/t/galera_mdev_13787.opt new file mode 100644 index 00000000000..27ec1e3f00e --- /dev/null +++ b/mysql-test/suite/galera/t/galera_mdev_13787.opt @@ -0,0 +1 @@ +--innodb-stats-persistent=1 diff --git a/mysql-test/suite/galera/t/galera_mdev_13787.test b/mysql-test/suite/galera/t/galera_mdev_13787.test new file mode 100644 index 00000000000..940cffb8b65 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_mdev_13787.test @@ -0,0 +1,6 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc +--connection node_1 +create table t(a int); +insert into t select 1; +DROP TABLE t; diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index 33689a91661..061f877da6e 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -2293,7 +2293,7 @@ static int wsrep_create_sp(THD *thd, uchar** buf, size_t* buf_len) } -extern int wsrep_on(THD *thd) +extern inline int wsrep_on(THD *thd) { return (int)(WSREP(thd)); } diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index afc320de517..e50f9fc9774 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -4122,7 +4122,7 @@ innobase_commit_low( trx_commit_for_mysql(trx); } #ifdef WITH_WSREP - if (wsrep_on(thd)) { thd_proc_info(thd, tmp); } + if (thd && wsrep_on(thd)) { thd_proc_info(thd, tmp); } #endif /* WITH_WSREP */ } diff --git a/storage/innobase/include/lock0lock.h b/storage/innobase/include/lock0lock.h index 8c63157ea8e..62bbd572068 100644 --- a/storage/innobase/include/lock0lock.h +++ b/storage/innobase/include/lock0lock.h @@ -1024,6 +1024,11 @@ std::string lock_get_info( const lock_t*); +/*******************************************************************//** +@return whether wsrep_on is true on trx->mysql_thd*/ +bool +wsrep_on_trx(const trx_t* trx); + #endif /* WITH_WSREP */ #ifndef UNIV_NONINL #include "lock0lock.ic" diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc index 3f5489fbc19..cedf08322b7 100644 --- a/storage/innobase/lock/lock0lock.cc +++ b/storage/innobase/lock/lock0lock.cc @@ -1825,7 +1825,7 @@ lock_rec_other_has_conflicting( #ifdef WITH_WSREP if (lock_rec_has_to_wait(TRUE, trx, mode, lock, is_supremum)) { - if (wsrep_on(trx->mysql_thd)) { + if (wsrep_on_trx(trx)) { trx_mutex_enter(lock->trx); wsrep_kill_victim(trx, lock); trx_mutex_exit(lock->trx); @@ -2151,7 +2151,7 @@ lock_rec_create( #ifdef WITH_WSREP if (c_lock && - wsrep_on(trx->mysql_thd) && + wsrep_on_trx(trx) && wsrep_thd_is_BF(trx->mysql_thd, FALSE)) { lock_t *hash = (lock_t *)c_lock->hash; lock_t *prev = NULL; @@ -8213,3 +8213,11 @@ lock_get_info( return info; } + +#ifdef WITH_WSREP +bool inline +wsrep_on_trx(const trx_t* trx) +{ + return trx->mysql_thd && wsrep_on(trx->mysql_thd); +} +#endif /* WITH_WSREP */ diff --git a/storage/innobase/lock/lock0wait.cc b/storage/innobase/lock/lock0wait.cc index a447027e336..ca9d05a4829 100644 --- a/storage/innobase/lock/lock0wait.cc +++ b/storage/innobase/lock/lock0wait.cc @@ -197,7 +197,7 @@ wsrep_is_BF_lock_timeout( /*====================*/ trx_t* trx) /* in: trx to check for lock priority */ { - if (wsrep_on(trx->mysql_thd) && + if (wsrep_on_trx(trx) && wsrep_thd_is_BF(trx->mysql_thd, FALSE)) { fprintf(stderr, "WSREP: BF lock wait long\n"); srv_print_innodb_monitor = TRUE; @@ -402,7 +402,7 @@ lock_wait_suspend_thread( if (lock_wait_timeout < 100000000 && wait_time > (double) lock_wait_timeout) { #ifdef WITH_WSREP - if (!wsrep_on(trx->mysql_thd) || + if (!wsrep_on_trx(trx) || (!wsrep_is_BF_lock_timeout(trx) && trx->error_state != DB_DEADLOCK)) { #endif /* WITH_WSREP */ diff --git a/storage/innobase/row/row0upd.cc b/storage/innobase/row/row0upd.cc index 85a4b0bdf19..ba874ac6dec 100644 --- a/storage/innobase/row/row0upd.cc +++ b/storage/innobase/row/row0upd.cc @@ -1983,7 +1983,7 @@ row_upd_sec_index_entry( } #ifdef WITH_WSREP if (err == DB_SUCCESS && !referenced && - wsrep_on(trx->mysql_thd) && + wsrep_on_trx(trx) && !wsrep_thd_is_BF(trx->mysql_thd, FALSE) && !(parent && que_node_get_type(parent) == QUE_NODE_UPDATE && @@ -2270,7 +2270,7 @@ err_exit: } } #ifdef WITH_WSREP - if (!referenced && wsrep_on(trx->mysql_thd) && + if (!referenced && wsrep_on_trx(trx) && !(parent && que_node_get_type(parent) == QUE_NODE_UPDATE && ((upd_node_t*)parent)->cascade_node == node) && foreign @@ -2536,8 +2536,7 @@ row_upd_del_mark_clust_rec( } #ifdef WITH_WSREP trx_t* trx = thr_get_trx(thr) ; - - if (err == DB_SUCCESS && !referenced && trx && wsrep_on(trx->mysql_thd) && + if (err == DB_SUCCESS && !referenced && wsrep_on_trx(trx) && !(parent && que_node_get_type(parent) == QUE_NODE_UPDATE && ((upd_node_t*)parent)->cascade_node == node) && foreign diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc index 3517eee0380..8763fab5a85 100644 --- a/storage/xtradb/handler/ha_innodb.cc +++ b/storage/xtradb/handler/ha_innodb.cc @@ -4633,7 +4633,7 @@ innobase_commit_low( trx_commit_for_mysql(trx); } #ifdef WITH_WSREP - if (wsrep_on(thd)) { thd_proc_info(thd, tmp); } + if (thd && wsrep_on(thd)) { thd_proc_info(thd, tmp); } #endif /* WITH_WSREP */ } diff --git a/storage/xtradb/include/lock0lock.h b/storage/xtradb/include/lock0lock.h index 923c463aa22..5f8e7b1c878 100644 --- a/storage/xtradb/include/lock0lock.h +++ b/storage/xtradb/include/lock0lock.h @@ -1028,6 +1028,14 @@ Get lock mode and table/index name std::string lock_get_info( const lock_t*); +#ifdef WITH_WSREP + +/*******************************************************************//** +@return whether wsrep_on is true on trx->mysql_thd*/ +bool +wsrep_on_trx(const trx_t* trx); + +#endif /* WITH_WSREP */ #ifndef UNIV_NONINL #include "lock0lock.ic" diff --git a/storage/xtradb/lock/lock0lock.cc b/storage/xtradb/lock/lock0lock.cc index 40ab9d9403c..40511b60f49 100644 --- a/storage/xtradb/lock/lock0lock.cc +++ b/storage/xtradb/lock/lock0lock.cc @@ -1835,7 +1835,7 @@ lock_rec_other_has_conflicting( #ifdef WITH_WSREP if (lock_rec_has_to_wait(TRUE, trx, mode, lock, is_supremum)) { - if (wsrep_on(trx->mysql_thd)) { + if (wsrep_on_trx(trx)) { trx_mutex_enter(lock->trx); wsrep_kill_victim(trx, lock); trx_mutex_exit(lock->trx); @@ -2290,7 +2290,7 @@ lock_rec_create( #ifdef WITH_WSREP if (c_lock && - wsrep_on(trx->mysql_thd) && + wsrep_on_trx(trx) && wsrep_thd_is_BF(trx->mysql_thd, FALSE)) { lock_t *hash = (lock_t *)c_lock->hash; lock_t *prev = NULL; @@ -8336,3 +8336,11 @@ lock_get_info( return info; } + +#ifdef WITH_WSREP +bool inline +wsrep_on_trx(const trx_t* trx) +{ + return trx->mysql_thd && wsrep_on(trx->mysql_thd); +} +#endif /* WITH_WSREP */ diff --git a/storage/xtradb/lock/lock0wait.cc b/storage/xtradb/lock/lock0wait.cc index a447027e336..ca9d05a4829 100644 --- a/storage/xtradb/lock/lock0wait.cc +++ b/storage/xtradb/lock/lock0wait.cc @@ -197,7 +197,7 @@ wsrep_is_BF_lock_timeout( /*====================*/ trx_t* trx) /* in: trx to check for lock priority */ { - if (wsrep_on(trx->mysql_thd) && + if (wsrep_on_trx(trx) && wsrep_thd_is_BF(trx->mysql_thd, FALSE)) { fprintf(stderr, "WSREP: BF lock wait long\n"); srv_print_innodb_monitor = TRUE; @@ -402,7 +402,7 @@ lock_wait_suspend_thread( if (lock_wait_timeout < 100000000 && wait_time > (double) lock_wait_timeout) { #ifdef WITH_WSREP - if (!wsrep_on(trx->mysql_thd) || + if (!wsrep_on_trx(trx) || (!wsrep_is_BF_lock_timeout(trx) && trx->error_state != DB_DEADLOCK)) { #endif /* WITH_WSREP */ diff --git a/storage/xtradb/row/row0upd.cc b/storage/xtradb/row/row0upd.cc index 91dbc5252bc..91f7fb30e81 100644 --- a/storage/xtradb/row/row0upd.cc +++ b/storage/xtradb/row/row0upd.cc @@ -1989,7 +1989,7 @@ row_upd_sec_index_entry( } #ifdef WITH_WSREP if (err == DB_SUCCESS && !referenced && - wsrep_on(trx->mysql_thd) && + wsrep_on_trx(trx) && !wsrep_thd_is_BF(trx->mysql_thd, FALSE) && !(parent && que_node_get_type(parent) == QUE_NODE_UPDATE && @@ -2279,7 +2279,7 @@ err_exit: } } #ifdef WITH_WSREP - if (!referenced && wsrep_on(trx->mysql_thd) && + if (!referenced && wsrep_on_trx(trx) && !(parent && que_node_get_type(parent) == QUE_NODE_UPDATE && ((upd_node_t*)parent)->cascade_node == node) && foreign @@ -2548,8 +2548,7 @@ row_upd_del_mark_clust_rec( } #ifdef WITH_WSREP trx_t* trx = thr_get_trx(thr) ; - - if (err == DB_SUCCESS && !referenced && trx && wsrep_on(trx->mysql_thd) && + if (err == DB_SUCCESS && !referenced && wsrep_on_trx(trx) && !(parent && que_node_get_type(parent) == QUE_NODE_UPDATE && ((upd_node_t*)parent)->cascade_node == node) && foreign