From 848c4c4fd2aefee591f336d052b44ad1443e18ac Mon Sep 17 00:00:00 2001 From: obdev Date: Wed, 7 Feb 2024 21:10:12 +0000 Subject: [PATCH] add sys log for macro ref diagnosis --- src/storage/tablet/ob_tablet.cpp | 53 ++++++++++++++++++++++++++++++++ src/storage/tablet/ob_tablet.h | 1 + 2 files changed, 54 insertions(+) diff --git a/src/storage/tablet/ob_tablet.cpp b/src/storage/tablet/ob_tablet.cpp index 6f62c9901..d55923ebb 100644 --- a/src/storage/tablet/ob_tablet.cpp +++ b/src/storage/tablet/ob_tablet.cpp @@ -2360,6 +2360,8 @@ int ObTablet::inc_ref_with_macro_iter(ObMacroInfoIterator ¯o_iter, bool &inc int inc_other_ref_cnt = 0; ObTabletBlockInfo block_info; inc_success = false; + ObSArray print_arr; + print_arr.set_attr(ObMemAttr(MTL_ID(), "PrintId", ObCtxIds::DEFAULT_CTX_ID)); while (OB_SUCC(ret)) { block_info.reset(); if (OB_FAIL(macro_iter.get_next(block_info))) { @@ -2373,7 +2375,24 @@ int ObTablet::inc_ref_with_macro_iter(ObMacroInfoIterator ¯o_iter, bool &inc && OB_FAIL(MTL(ObSharedMacroBlockMgr*)->add_block(block_info.macro_id_, block_info.occupy_size_))) { LOG_WARN("fail to add block", K(ret), K(block_info)); } +#ifndef OB_BUILD_RPM + int tmp_ret = OB_SUCCESS; + if (OB_FAIL(ret)) { + // do nothing + } else if (OB_TMP_FAIL(print_arr.push_back(block_info.macro_id_))) { + LOG_WARN("fail to push macro id into print array", K(tmp_ret)); + } else if (MAX_PRINT_COUNT == print_arr.size()) { + FLOG_INFO("increase tablet's macro ref", K(ret), K(print_arr)); + print_arr.reuse(); + } +#endif } +#ifndef OB_BUILD_RPM + if (0 != print_arr.count()) { + FLOG_INFO("increase tablet's macro ref", K(ret), K(print_arr)); + print_arr.reuse(); + } +#endif if (OB_LIKELY(OB_ITER_END == ret) || OB_SUCC(ret)) { inc_success = true; @@ -2393,7 +2412,23 @@ int ObTablet::inc_ref_with_macro_iter(ObMacroInfoIterator ¯o_iter, bool &inc && OB_TMP_FAIL(MTL(ObSharedMacroBlockMgr*)->free_block(block_info.macro_id_, block_info.occupy_size_))) { LOG_WARN("fail to free block", K(ret), K(block_info)); } +#ifndef OB_BUILD_RPM + if (OB_FAIL(tmp_ret)) { + // do nothing + } else if (OB_TMP_FAIL(print_arr.push_back(block_info.macro_id_))) { + LOG_WARN("fail to push macro id into print array", K(tmp_ret)); + } else if (MAX_PRINT_COUNT == print_arr.size()) { + FLOG_INFO("decrease tablet's macro ref", K(ret), K(print_arr)); + print_arr.reuse(); + } +#endif } +#ifndef OB_BUILD_RPM + if (0 != print_arr.count()) { + FLOG_INFO("decrease tablet's macro ref", K(ret), K(print_arr)); + print_arr.reuse(); + } +#endif } } @@ -2572,6 +2607,8 @@ void ObTablet::dec_ref_with_macro_iter(ObMacroInfoIterator ¯o_iter) const { int ret = OB_SUCCESS; ObTabletBlockInfo block_info; + ObSArray print_arr; + print_arr.set_attr(ObMemAttr(MTL_ID(), "PrintId", ObCtxIds::DEFAULT_CTX_ID)); while (OB_SUCC(ret)) { block_info.reset(); if (OB_FAIL(macro_iter.get_next(block_info))) { @@ -2585,12 +2622,28 @@ void ObTablet::dec_ref_with_macro_iter(ObMacroInfoIterator ¯o_iter) const && OB_FAIL(MTL(ObSharedMacroBlockMgr*)->free_block(block_info.macro_id_, block_info.occupy_size_))) { LOG_WARN("fail to add block", K(ret), K(block_info)); } + int tmp_ret = OB_SUCCESS; if (OB_FAIL(ret)) { ret = OB_SUCCESS; // ignore ret, continue + } else { +#ifndef OB_BUILD_RPM + if (OB_TMP_FAIL(print_arr.push_back(block_info.macro_id_))) { + LOG_WARN("fail to push macro id into print array", K(tmp_ret)); + } else if (MAX_PRINT_COUNT == print_arr.size()) { + FLOG_INFO("decrease tablet's macro ref", K(ret), K(print_arr)); + print_arr.reuse(); + } +#endif } } } +#ifndef OB_BUILD_RPM + if (0 != print_arr.size()) { + FLOG_INFO("decrease tablet's macro ref", K(ret), K(print_arr)); + print_arr.reuse(); + } +#endif } int ObTablet::inc_table_store_ref_cnt(bool &inc_success) diff --git a/src/storage/tablet/ob_tablet.h b/src/storage/tablet/ob_tablet.h index 719efbd96..a75bd21b8 100644 --- a/src/storage/tablet/ob_tablet.h +++ b/src/storage/tablet/ob_tablet.h @@ -827,6 +827,7 @@ private: static const int64_t DDL_KV_ARRAY_SIZE = 64; static const int64_t ON_DEMAND_LOAD_SIZE = 4096; //4k static const int64_t SHARED_MACRO_BUCKET_CNT = 100; + static const int64_t MAX_PRINT_COUNT = 100; private: int32_t version_; int32_t length_;