From a3168c3fbe888515bbde65f74dfba369fbc08184 Mon Sep 17 00:00:00 2001 From: Fengjingkun Date: Thu, 4 Jul 2024 04:15:22 +0000 Subject: [PATCH] fix mem reuse when persisting large co sstable --- src/storage/tablet/ob_tablet_persister.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/storage/tablet/ob_tablet_persister.cpp b/src/storage/tablet/ob_tablet_persister.cpp index 170ba549d..b4b54b2fe 100644 --- a/src/storage/tablet/ob_tablet_persister.cpp +++ b/src/storage/tablet/ob_tablet_persister.cpp @@ -1086,6 +1086,7 @@ int ObTabletPersister::fetch_and_persist_sstable( int ret = OB_SUCCESS; SharedMacroMap shared_macro_map; common::ObSEArray tables; + common::ObSEArray big_co_tables; // used to recycle mem common::ObSEArray addrs; common::ObSEArray cg_addrs; common::ObSEArray write_ctxs; @@ -1094,6 +1095,7 @@ int ObTabletPersister::fetch_and_persist_sstable( ? ObCtxIds::MERGE_RESERVE_CTX_ID : ObCtxIds::DEFAULT_CTX_ID; tables.set_attr(lib::ObMemAttr(MTL_ID(), "PerstTables", ctx_id)); + big_co_tables.set_attr(lib::ObMemAttr(MTL_ID(), "PerstBigTbls", ctx_id)); addrs.set_attr(lib::ObMemAttr(MTL_ID(), "PerstAddrs", ctx_id)); cg_addrs.set_attr(lib::ObMemAttr(MTL_ID(), "PerstCGAddrs", ctx_id)); write_ctxs.set_attr(lib::ObMemAttr(MTL_ID(), "PerstWriteCtxs", ctx_id)); @@ -1122,7 +1124,6 @@ int ObTabletPersister::fetch_and_persist_sstable( // serialize full co sstable and shell cg sstables when the serialize size of CO reached the limit. FLOG_INFO("cannot full serialize CO within 2MB buffer, should serialize CO with Shell CG", K(ret), KPC(table)); cg_addrs.reset(); - tmp_allocator.reuse(); ObCOSSTableV2 *tmp_co_sstable = nullptr; ObSSTableMetaHandle co_meta_handle; @@ -1140,6 +1141,8 @@ int ObTabletPersister::fetch_and_persist_sstable( LOG_WARN("failed to fill sstable write info", K(ret)); } else if (OB_FAIL(tables.push_back(tmp_co_sstable))) { LOG_WARN("failed to add table", K(ret)); + } else if (OB_FAIL(big_co_tables.push_back(tmp_co_sstable))) { + LOG_WARN("failed to add co to big tables", K(ret)); } else if (OB_FAIL(copy_sstable_macro_info(*tmp_co_sstable, shared_macro_map, block_info_set))) { LOG_WARN("fail to call sstable macro info", K(ret)); } @@ -1226,6 +1229,15 @@ int ObTabletPersister::fetch_and_persist_sstable( } total_tablet_meta_size += upper_align(sstable_meta_size, DIO_READ_ALIGN_SIZE); } + + // recycle big co table mem + for (int64_t idx = 0; idx < big_co_tables.count(); ++idx) { + ObCOSSTableV2 *co_table = big_co_tables.at(idx); + if (OB_NOT_NULL(co_table)) { + co_table->~ObCOSSTableV2(); + tmp_allocator.free(co_table); + } + } return ret; }