diff --git a/src/storage/tx/ob_trans_define_v4.cpp b/src/storage/tx/ob_trans_define_v4.cpp index 327e549ae2..1c55cda12a 100644 --- a/src/storage/tx/ob_trans_define_v4.cpp +++ b/src/storage/tx/ob_trans_define_v4.cpp @@ -928,6 +928,13 @@ bool ObTxDesc::execute_commit_cb() executed = true; cb = commit_cb_; commit_cb_ = NULL; + if (0 <= cb_tid_) { +#ifdef ENABLE_DEBUG_LOG + ob_abort(); +#endif + TRANS_LOG(WARN, "unexpected error happen, cb_tid_ should smaller than 0", + KP(this), K(tx_id), KP(cb_tid_)); + } ATOMIC_STORE_REL(&cb_tid_, GETTID()); // NOTE: it is required add trace event before callback, // because txDesc may be released after callback called @@ -937,7 +944,7 @@ bool ObTxDesc::execute_commit_cb() OB_ID(thread_id), GETTID()); commit_cb_lock_.unlock(); cb->callback(commit_out_); - ATOMIC_STORE_REL(&cb_tid_, -1); + ATOMIC_STORE_REL(&cb_tid_, -GETTID()); } else { commit_cb_lock_.unlock(); } diff --git a/src/storage/tx/ob_tx_api.cpp b/src/storage/tx/ob_tx_api.cpp index c9476dd3cf..bf72bca13c 100644 --- a/src/storage/tx/ob_tx_api.cpp +++ b/src/storage/tx/ob_tx_api.cpp @@ -192,7 +192,7 @@ int ObTransService::reuse_tx(ObTxDesc &tx) PAUSE(); if (++spin_cnt > 2000) { TRANS_LOG(WARN, "blocking to wait tx referent quiescent cost too much time", - "tx_id", orig_tx_id, KP(&tx), K(final_ref_cnt), K(spin_cnt), K(tx.get_ref())); + "tx_id", orig_tx_id, KP(&tx), K(final_ref_cnt), K(spin_cnt), K(tx.get_ref()), K(cb_tid)); tx.print_trace(); usleep(2000000); // 2s } else if (spin_cnt > 200) { @@ -200,6 +200,12 @@ int ObTransService::reuse_tx(ObTxDesc &tx) } else if (spin_cnt > 100) { usleep(200); // 200us } +#ifdef ENABLE_DEBUG_LOG + if (spin_cnt > 2015) { + // at least wait 30s + ob_abort(); + } +#endif } // it is safe to operate tx without lock when not shared uint32_t session_id = tx.sess_id_;