From 8f6b152ac866645a3c0af9a196c3920d735b7a84 Mon Sep 17 00:00:00 2001 From: chinaxing Date: Wed, 17 May 2023 15:16:45 +0000 Subject: [PATCH] [master] fix sampling sql caused txn free route defensive check false positve --- src/sql/optimizer/ob_dynamic_sampling.cpp | 13 ++++++++++++- src/storage/tx/ob_tx_free_route.cpp | 4 ++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/sql/optimizer/ob_dynamic_sampling.cpp b/src/sql/optimizer/ob_dynamic_sampling.cpp index a35b55e9d..f6226a844 100644 --- a/src/sql/optimizer/ob_dynamic_sampling.cpp +++ b/src/sql/optimizer/ob_dynamic_sampling.cpp @@ -1070,6 +1070,17 @@ int ObDynamicSampling::restore_session(ObSQLSessionInfo *session, session->set_sql_mode(session->get_sql_mode() | SMO_NO_BACKSLASH_ESCAPES); } if (tx_desc != NULL) {//reset origin tx desc. + // release curr + if (OB_NOT_NULL(session->get_tx_desc())) { + auto txs = MTL(transaction::ObTransService*); + if (OB_ISNULL(txs)) { + ret = OB_ERR_UNEXPECTED; + LOG_ERROR("can not acquire MTL TransService", KR(ret)); + session->get_tx_desc()->dump_and_print_trace(); + } else { + txs->release_tx(*session->get_tx_desc()); + } + } session->get_tx_desc() = tx_desc; } } @@ -1909,4 +1920,4 @@ bool ObDynamicSamplingUtils::is_ds_virtual_table(const int64_t table_id) // } } // end of namespace common -} // end of namespace oceanbase \ No newline at end of file +} // end of namespace oceanbase diff --git a/src/storage/tx/ob_tx_free_route.cpp b/src/storage/tx/ob_tx_free_route.cpp index 82463b1ad..2739f9f43 100644 --- a/src/storage/tx/ob_tx_free_route.cpp +++ b/src/storage/tx/ob_tx_free_route.cpp @@ -36,8 +36,8 @@ int64_t MAX_STATE_SIZE = 4 * 1024; // 4KB bool ObTxnFreeRouteCtx::is_temp(const ObTxDesc &tx) const { - UNUSED(tx); - return txn_addr_.is_valid() && txn_addr_ != GCONF.self_addr_; + // match against tx_id to allow other txn commit or rollback on temp node + return tx_id_ == tx.tx_id_ && txn_addr_.is_valid() && txn_addr_ != GCONF.self_addr_; } void ObTxnFreeRouteCtx::init_before_update_state(bool proxy_support) {