From 10799a599b87abd39011bab0acee82ac75114e75 Mon Sep 17 00:00:00 2001 From: Tyshawn Date: Thu, 19 Aug 2021 17:36:56 +0800 Subject: [PATCH] [Tmp.File] fix prefetch handle issue --- src/storage/blocksstable/ob_tmp_file.h | 4 ++-- .../blocksstable/ob_tmp_file_cache.cpp | 19 +++++++++---------- src/storage/blocksstable/ob_tmp_file_cache.h | 17 ++++++++--------- .../blocksstable/ob_tmp_file_store.cpp | 4 ++-- 4 files changed, 21 insertions(+), 23 deletions(-) diff --git a/src/storage/blocksstable/ob_tmp_file.h b/src/storage/blocksstable/ob_tmp_file.h index c05b0e67b0..0641bff084 100644 --- a/src/storage/blocksstable/ob_tmp_file.h +++ b/src/storage/blocksstable/ob_tmp_file.h @@ -374,7 +374,7 @@ private: : tenant_id_(tenant_id), fd_list_(fd_list) {} ~RmTenantTmpFileOp() = default; - bool operator()(common::hash::HashMapPair& entry) + int operator()(common::hash::HashMapPair &entry) { int ret = OB_SUCCESS; ObTmpFile* tmp_file = entry.second; @@ -386,7 +386,7 @@ private: STORAGE_LOG(WARN, "fd_list_ push back failed", K(ret)); } } - return OB_SUCCESS == ret; + return ret; } private: diff --git a/src/storage/blocksstable/ob_tmp_file_cache.cpp b/src/storage/blocksstable/ob_tmp_file_cache.cpp index ae6680caa1..b7f3624f27 100644 --- a/src/storage/blocksstable/ob_tmp_file_cache.cpp +++ b/src/storage/blocksstable/ob_tmp_file_cache.cpp @@ -103,13 +103,12 @@ int ObTmpPageCacheValue::deep_copy(char* buf, const int64_t buf_len, ObIKVCacheV return ret; } -int ObTmpPageCache::prefetch(const ObTmpPageCacheKey& key, const ObTmpBlockIOInfo& info, ObTmpFileIOHandle& handle, - ObMacroBlockHandle& mb_handle) +int ObTmpPageCache::prefetch(const ObTmpPageCacheKey &key, const ObTmpBlockIOInfo &info, ObMacroBlockHandle &mb_handle) { int ret = OB_SUCCESS; - if (OB_UNLIKELY(!key.is_valid() || !handle.is_valid())) { + if (OB_UNLIKELY(!key.is_valid())) { ret = OB_INVALID_ARGUMENT; - STORAGE_LOG(WARN, "Invalid arguments", K(ret), K(key), K(handle)); + STORAGE_LOG(WARN, "Invalid arguments", K(ret), K(key)); } else { // fill the callback ObTmpPageIOCallback callback; @@ -122,7 +121,7 @@ int ObTmpPageCache::prefetch(const ObTmpPageCacheKey& key, const ObTmpBlockIOInf if (mb_handle.get_io_handle().is_empty()) { // TODO: After the continuous IO has been optimized, this should // not happen. - if (OB_FAIL(handle.wait(DEFAULT_IO_WAIT_TIME_MS))) { + if (OB_FAIL(mb_handle.wait(DEFAULT_IO_WAIT_TIME_MS))) { STORAGE_LOG(WARN, "fail to wait tmp page io", K(ret)); } else if (OB_FAIL(read_io(info, callback, mb_handle))) { STORAGE_LOG(WARN, "fail to read tmp page from io", K(ret)); @@ -135,13 +134,13 @@ int ObTmpPageCache::prefetch(const ObTmpPageCacheKey& key, const ObTmpBlockIOInf return ret; } -int ObTmpPageCache::prefetch(const ObTmpBlockIOInfo& info, const common::ObIArray& page_io_infos, - ObTmpFileIOHandle& handle, ObMacroBlockHandle& mb_handle) +int ObTmpPageCache::prefetch( + const ObTmpBlockIOInfo &info, const common::ObIArray &page_io_infos, ObMacroBlockHandle &mb_handle) { int ret = OB_SUCCESS; - if (OB_UNLIKELY(page_io_infos.count() <= 0 || !handle.is_valid())) { + if (OB_UNLIKELY(page_io_infos.count() <= 0)) { ret = OB_INVALID_ARGUMENT; - STORAGE_LOG(WARN, "Invalid arguments", K(ret), K(page_io_infos.count()), K(info), K(handle)); + STORAGE_LOG(WARN, "Invalid arguments", K(ret), K(page_io_infos.count()), K(info)); } else { ObTmpMultiPageIOCallback callback; callback.cache_ = this; @@ -159,7 +158,7 @@ int ObTmpPageCache::prefetch(const ObTmpBlockIOInfo& info, const common::ObIArra if (mb_handle.get_io_handle().is_empty()) { // TODO: After the continuous IO has been optimized, this should // not happen. - if (OB_FAIL(handle.wait(DEFAULT_IO_WAIT_TIME_MS))) { + if (OB_FAIL(mb_handle.wait(DEFAULT_IO_WAIT_TIME_MS))) { STORAGE_LOG(WARN, "fail to wait tmp page io", K(ret)); } else if (OB_FAIL(read_io(info, callback, mb_handle))) { STORAGE_LOG(WARN, "fail to read tmp page from io", K(ret)); diff --git a/src/storage/blocksstable/ob_tmp_file_cache.h b/src/storage/blocksstable/ob_tmp_file_cache.h index 3cb548a703..d50bb25a1d 100644 --- a/src/storage/blocksstable/ob_tmp_file_cache.h +++ b/src/storage/blocksstable/ob_tmp_file_cache.h @@ -108,16 +108,15 @@ public: class ObTmpPageCache : public common::ObKVCache { public: typedef common::ObKVCache BasePageCache; - static ObTmpPageCache& get_instance(); - int init(const char* cache_name, const int64_t priority, const ObStorageFileHandle& file_handle); - int prefetch(const ObTmpPageCacheKey& key, const ObTmpBlockIOInfo& info, ObTmpFileIOHandle& handle, - ObMacroBlockHandle& mb_handle); + static ObTmpPageCache &get_instance(); + int init(const char *cache_name, const int64_t priority, const ObStorageFileHandle &file_handle); + int prefetch(const ObTmpPageCacheKey &key, const ObTmpBlockIOInfo &info, ObMacroBlockHandle &mb_handle); // multi page prefetch - int prefetch(const ObTmpBlockIOInfo& info, const common::ObIArray& page_io_infos, - ObTmpFileIOHandle& handle, ObMacroBlockHandle& mb_handle); - int get_cache_page(const ObTmpPageCacheKey& key, ObTmpPageValueHandle& handle); - int get_page(const ObTmpPageCacheKey& key, ObTmpPageValueHandle& handle); - int put_page(const ObTmpPageCacheKey& key, const ObTmpPageCacheValue& value); + int prefetch(const ObTmpBlockIOInfo &info, const common::ObIArray &page_io_infos, + ObMacroBlockHandle &mb_handle); + int get_cache_page(const ObTmpPageCacheKey &key, ObTmpPageValueHandle &handle); + int get_page(const ObTmpPageCacheKey &key, ObTmpPageValueHandle &handle); + int put_page(const ObTmpPageCacheKey &key, const ObTmpPageCacheValue &value); void destroy(); public: diff --git a/src/storage/blocksstable/ob_tmp_file_store.cpp b/src/storage/blocksstable/ob_tmp_file_store.cpp index e78b43e86f..ca88cc5c70 100644 --- a/src/storage/blocksstable/ob_tmp_file_store.cpp +++ b/src/storage/blocksstable/ob_tmp_file_store.cpp @@ -1059,7 +1059,7 @@ int ObTmpTenantFileStore::read_page(ObTmpMacroBlock* block, ObTmpBlockIOInfo& io info.offset_ = common::lower_align(io_info.offset_, ObTmpMacroBlock::get_default_page_size()); info.size_ = page_nums * ObTmpMacroBlock::get_default_page_size(); info.macro_block_id_ = block->get_macro_block_id(); - if (OB_FAIL(page_cache_->prefetch(info, page_io_infos, handle, mb_handle))) { + if (OB_FAIL(page_cache_->prefetch(info, page_io_infos, mb_handle))) { STORAGE_LOG(WARN, "fail to prefetch multi tmp page", K(ret)); } else { ObTmpFileIOHandle::ObIOReadHandle read_handle( @@ -1076,7 +1076,7 @@ int ObTmpTenantFileStore::read_page(ObTmpMacroBlock* block, ObTmpBlockIOInfo& io info.offset_ = page_io_infos.at(i).key_.get_page_id() * ObTmpMacroBlock::get_default_page_size(); info.size_ = ObTmpMacroBlock::get_default_page_size(); info.macro_block_id_ = block->get_macro_block_id(); - if (OB_FAIL(page_cache_->prefetch(page_io_infos.at(i).key_, info, handle, mb_handle))) { + if (OB_FAIL(page_cache_->prefetch(page_io_infos.at(i).key_, info, mb_handle))) { STORAGE_LOG(WARN, "fail to prefetch tmp page", K(ret)); } else { char* buf = -- GitLab