diff --git a/src/storage/tx/ob_trans_part_ctx.cpp b/src/storage/tx/ob_trans_part_ctx.cpp index 1fa708f733..c71a07181c 100644 --- a/src/storage/tx/ob_trans_part_ctx.cpp +++ b/src/storage/tx/ob_trans_part_ctx.cpp @@ -5895,11 +5895,11 @@ int ObPartTransCtx::insert_into_retain_ctx_mgr_(RetainCause cause, retain_lock_timeout = 10 * 1000; } + ObTxRetainCtxMgr &retain_ctx_mgr = ls_tx_ctx_mgr_->get_retain_ctx_mgr(); if (OB_ISNULL(ls_tx_ctx_mgr_) || RetainCause::UNKOWN == cause) { ret = OB_INVALID_ARGUMENT; TRANS_LOG(WARN, "invalid argument", K(ret), K(cause), KP(ls_tx_ctx_mgr_), KPC(this)); } else { - ObTxRetainCtxMgr &retain_ctx_mgr = ls_tx_ctx_mgr_->get_retain_ctx_mgr(); if (OB_ISNULL(retain_func_ptr = static_cast( retain_ctx_mgr.alloc_object((sizeof(ObMDSRetainCtxFunctor)))))) { @@ -5915,12 +5915,18 @@ int ObPartTransCtx::insert_into_retain_ctx_mgr_(RetainCause cause, // if (OB_FAIL(retain_ctx_mgr.reset())) } - if (OB_FAIL(ret) && !(OB_EAGAIN == ret && for_replay)) { - TRANS_LOG(ERROR, "insert into retain_ctx_mgr error, retain ctx will not deleted from ctx_mgr", - K(ret), KPC(this)); - // ob_abort(); + if (OB_FAIL(ret)) { + clean_retain_cause_(); + if (retain_func_ptr != nullptr) { + retain_ctx_mgr.free_object(retain_func_ptr); + retain_func_ptr = nullptr; + } + if (!(OB_EAGAIN == ret && for_replay)) { + TRANS_LOG(ERROR, "insert into retain_ctx_mgr error, retain ctx will not deleted from ctx_mgr", + K(ret), KPC(this)); + // ob_abort(); + } } - return ret; } diff --git a/src/storage/tx/ob_tx_retain_ctx_mgr.cpp b/src/storage/tx/ob_tx_retain_ctx_mgr.cpp index 8e1cec23a3..6d0359ae7a 100644 --- a/src/storage/tx/ob_tx_retain_ctx_mgr.cpp +++ b/src/storage/tx/ob_tx_retain_ctx_mgr.cpp @@ -240,10 +240,14 @@ int ObTxRetainCtxMgr::force_gc_retain_ctx() SpinWLockGuard guard(retain_ctx_lock_); tg.click(); + const int64_t before_remove_count = retain_ctx_list_.size(); if (OB_FAIL(for_each_remove_(&ObTxRetainCtxMgr::force_gc_, nullptr, INT64_MAX))) { TRANS_LOG(WARN, "[RetainCtxMgr] force gc all retain ctx faild", K(ret)); } + TRANS_LOG(INFO, "[RetainCtxMgr] force gc all retain ctx", K(ret), K(before_remove_count), + KPC(this)); + return ret; } diff --git a/src/storage/tx/ob_tx_retain_ctx_mgr.h b/src/storage/tx/ob_tx_retain_ctx_mgr.h index 92c0ddba0f..2af2b96e94 100644 --- a/src/storage/tx/ob_tx_retain_ctx_mgr.h +++ b/src/storage/tx/ob_tx_retain_ctx_mgr.h @@ -122,7 +122,10 @@ public: void try_advance_retain_ctx_gc(share::ObLSID ls_id); - TO_STRING_KV(K(retain_ctx_list_.size())); + TO_STRING_KV(K(retain_ctx_list_.size()), + K(max_wait_ckpt_ts_), + K(last_push_gc_task_ts_), + K(skip_remove_cnt_)); private: int remove_ctx_func_(RetainCtxList::iterator remove_iter);