From b3710455bfbbfa56eda3c3786ef8d27598cac8e2 Mon Sep 17 00:00:00 2001 From: obdev Date: Wed, 17 May 2023 10:11:17 +0000 Subject: [PATCH] fix ObTxExecResult memory inflation when registering mds --- src/storage/tx/ob_trans_define_v4.cpp | 10 ++++++---- src/storage/tx/ob_trans_define_v4.h | 1 + src/storage/tx/ob_trans_part_ctx.h | 6 ++++-- src/storage/tx/ob_trans_service.cpp | 2 ++ 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/storage/tx/ob_trans_define_v4.cpp b/src/storage/tx/ob_trans_define_v4.cpp index 7b07ef6f93..14b4424647 100644 --- a/src/storage/tx/ob_trans_define_v4.cpp +++ b/src/storage/tx/ob_trans_define_v4.cpp @@ -1107,10 +1107,11 @@ ObString ObTxReadSnapshot::get_source_name() const } ObTxExecResult::ObTxExecResult() - : incomplete_(false), - touched_ls_list_(), - parts_(), - cflict_txs_() + : allocator_("TxExecResult", MTL_ID()), + incomplete_(false), + touched_ls_list_(OB_MALLOC_NORMAL_BLOCK_SIZE, allocator_), + parts_(OB_MALLOC_NORMAL_BLOCK_SIZE, allocator_), + cflict_txs_(OB_MALLOC_NORMAL_BLOCK_SIZE, allocator_) {} ObTxExecResult::~ObTxExecResult() @@ -1124,6 +1125,7 @@ void ObTxExecResult::reset() touched_ls_list_.reset(); parts_.reset(); cflict_txs_.reset(); + allocator_.reset(); } int ObTxExecResult::add_touched_ls(const share::ObLSID ls) diff --git a/src/storage/tx/ob_trans_define_v4.h b/src/storage/tx/ob_trans_define_v4.h index 1242333a26..4f4c4b814c 100644 --- a/src/storage/tx/ob_trans_define_v4.h +++ b/src/storage/tx/ob_trans_define_v4.h @@ -300,6 +300,7 @@ class ObTxExecResult friend class ObTransService; friend class ObTxDesc; OB_UNIS_VERSION(1); + TransModulePageAllocator allocator_; bool incomplete_; // TODO: (yunxing.cyx) remove, required before sql use new API share::ObLSArray touched_ls_list_; ObTxPartList parts_; diff --git a/src/storage/tx/ob_trans_part_ctx.h b/src/storage/tx/ob_trans_part_ctx.h index f61b0797b4..2ffcbc0c67 100644 --- a/src/storage/tx/ob_trans_part_ctx.h +++ b/src/storage/tx/ob_trans_part_ctx.h @@ -99,7 +99,9 @@ class ObPartTransCtx : public ObTransCtx, public: ObPartTransCtx() : ObTransCtx("participant", ObTransCtxType::PARTICIPANT), ObTsCbTask(), - ObTxCycleTwoPhaseCommitter(), is_inited_(false), mt_ctx_(), exec_info_(reserve_allocator_), + ObTxCycleTwoPhaseCommitter(), + is_inited_(false), mt_ctx_(), reserve_allocator_("PartCtx", MTL_ID()), + exec_info_(reserve_allocator_), mds_cache_(reserve_allocator_), role_state_(TxCtxRoleState::FOLLOWER), coord_prepare_info_arr_(OB_MALLOC_NORMAL_BLOCK_SIZE, @@ -781,6 +783,7 @@ private: // data sequence no of first access int64_t first_scn_; private: + TransModulePageAllocator reserve_allocator_; // ======================================================== // newly added for 4.0 share::ObLSID ls_id_; @@ -841,7 +844,6 @@ private: const ObTxMsg * msg_2pc_cache_; share::SCN max_2pc_commit_scn_; ObLSLogInfoArray coord_prepare_info_arr_; - TransModulePageAllocator reserve_allocator_; // tmp scheduler addr is used to post response for the second phase of xa commit/rollback common::ObAddr tmp_scheduler_; // for standby diff --git a/src/storage/tx/ob_trans_service.cpp b/src/storage/tx/ob_trans_service.cpp index c4383e0dac..5840d3d093 100644 --- a/src/storage/tx/ob_trans_service.cpp +++ b/src/storage/tx/ob_trans_service.cpp @@ -737,6 +737,8 @@ int ObTransService::register_mds_into_tx(ObTxDesc &tx_desc, } else { time_guard.click("start register"); do { + result.reset(); + tx_result.reset(); if (OB_NOT_MASTER == ret) { ob_usleep(RETRY_INTERVAL); retry_cnt += 1;