fix TxDesc release when tenant removed and fix txdesc debug link-list broken

This commit is contained in:
chinaxing 2024-05-20 10:44:10 +00:00 committed by ob-robot
parent cefd6c6723
commit 8e6d0bc4bf
4 changed files with 34 additions and 2 deletions

View File

@ -334,6 +334,9 @@ void ObBasicSessionInfo::reset(bool skip_sys_var)
MAKE_TENANT_SWITCH_SCOPE_GUARD(guard);
if (OB_SUCC(guard.switch_to(tx_desc_->get_tenant_id(), false))) {
MTL(transaction::ObTransService*)->release_tx(*tx_desc_);
} else {
LOG_WARN("tenant env not exist, force release tx", KP(tx_desc_), K(tx_desc_->get_tx_id()));
transaction::ObTransService::force_release_tx_when_session_destroy(*tx_desc_);
}
tx_desc_ = NULL;
}

View File

@ -854,13 +854,20 @@ public:
, list_()
#endif
{}
#ifdef ENABLE_DEBUG_LOG
~ObTxDescAlloc()
{
ObSpinLockGuard guard(lk_);
list_.remove();
}
#endif
ObTxDesc* alloc_value()
{
ATOMIC_INC(&alloc_cnt_);
ObTxDesc *it = op_alloc(ObTxDesc);
#ifdef ENABLE_DEBUG_LOG
ObSpinLockGuard guard(lk_);
list_.insert(it->alloc_link_);
ObSpinLockGuard guard(lk_);
list_.insert(it->alloc_link_);
#endif
return it;
}
@ -875,6 +882,10 @@ public:
op_free(v);
}
}
static void force_free(ObTxDesc *v)
{
op_free(v);
}
int64_t get_alloc_cnt() const { return ATOMIC_LOAD(&alloc_cnt_); }
#ifdef ENABLE_DEBUG_LOG
template<typename Function>
@ -898,6 +909,9 @@ public:
ObTxDesc::DLink list_;
#endif
};
static void force_release(ObTxDesc &tx) {
ObTxDescAlloc::force_free(&tx);
}
share::ObLightHashMap<ObTransID, ObTxDesc, ObTxDescAlloc, common::SpinRWLock, 1 << 16 /*bucket_num*/> map_;
std::function<int(ObTransID&)> tx_id_allocator_;
ObTransService &txs_;

View File

@ -3932,5 +3932,15 @@ int ObTransService::handle_ask_tx_state_for_4377(const ObAskTxStateFor4377Msg &m
TRANS_LOG(INFO, "handle ask tx state for 4377", K(ret), K(msg), K(is_alive));
return ret;
}
void ObTransService::force_release_tx_when_session_destroy(ObTxDesc &tx)
{
{
ObSpinLockGuard guard(tx.lock_);
TRANS_LOG_RET(WARN, OB_SUCCESS, "txdesc will be released forcedly", K(tx));
tx.print_trace_();
}
ObTxDescMgr::force_release(tx);
}
} // transaction
} // ocenabase

View File

@ -21,6 +21,11 @@ int remove_ls(const share::ObLSID &ls_id,
*/
int acquire_tx(const char* buf, const int64_t len, int64_t &pos, ObTxDesc *&tx);
int release_tx_ref(ObTxDesc &tx);
/*
* used when session destroyed
* and TxDesc which referenced by session and the tenant unit has removed
*/
static void force_release_tx_when_session_destroy(ObTxDesc &tx);
/*
* interrupt any work in progress thread
*/