From 42a423f1cb90f139f72e55ac54872b939c5c73cd Mon Sep 17 00:00:00 2001 From: obdev Date: Wed, 18 Sep 2024 09:22:20 +0000 Subject: [PATCH] some bugfixes for tmp_file --- .../tmp_file/ob_tmp_file_test_helper.h | 2 +- .../mtlenv/storage/tmp_file/test_tmp_file.cpp | 20 +++++++++---------- .../tmp_file/test_tmp_file_flush_list.cpp | 2 +- .../tmp_file/ob_tmp_file_flush_manager.cpp | 6 ++++++ src/storage/tmp_file/ob_tmp_file_manager.cpp | 9 ++++++--- src/storage/tmp_file/ob_tmp_file_manager.h | 7 +++++-- 6 files changed, 29 insertions(+), 17 deletions(-) diff --git a/mittest/mtlenv/storage/tmp_file/ob_tmp_file_test_helper.h b/mittest/mtlenv/storage/tmp_file/ob_tmp_file_test_helper.h index 8a5029892..901a77a1c 100644 --- a/mittest/mtlenv/storage/tmp_file/ob_tmp_file_test_helper.h +++ b/mittest/mtlenv/storage/tmp_file/ob_tmp_file_test_helper.h @@ -445,7 +445,7 @@ void TestMultiTmpFileStress::run1() int64_t fd = 0; ObTenantEnv::set_tenant(tenant_ctx_); - ret = MTL(ObTenantTmpFileManager *)->open(fd, dir_id_); + ret = MTL(ObTenantTmpFileManager *)->open(fd, dir_id_, ""); std::cout << "normal case, fd: " << fd << std::endl; ASSERT_EQ(OB_SUCCESS, ret); STORAGE_LOG(INFO, "open file success", K(fd)); diff --git a/mittest/mtlenv/storage/tmp_file/test_tmp_file.cpp b/mittest/mtlenv/storage/tmp_file/test_tmp_file.cpp index a8dabe651..a5859ed18 100644 --- a/mittest/mtlenv/storage/tmp_file/test_tmp_file.cpp +++ b/mittest/mtlenv/storage/tmp_file/test_tmp_file.cpp @@ -145,7 +145,7 @@ TEST_F(TestTmpFile, test_unaligned_data_read_write) ObTmpFileIOHandle handle; ret = MTL(ObTenantTmpFileManager *)->alloc_dir(dir); ASSERT_EQ(OB_SUCCESS, ret); - ret = MTL(ObTenantTmpFileManager *)->open(fd, dir); + ret = MTL(ObTenantTmpFileManager *)->open(fd, dir, ""); std::cout << "open temporary file: " << fd << std::endl; ASSERT_EQ(OB_SUCCESS, ret); tmp_file::ObTmpFileHandle file_handle; @@ -260,7 +260,7 @@ TEST_F(TestTmpFile, test_read) int64_t fd = -1; ret = MTL(ObTenantTmpFileManager *)->alloc_dir(dir); ASSERT_EQ(OB_SUCCESS, ret); - ret = MTL(ObTenantTmpFileManager *)->open(fd, dir); + ret = MTL(ObTenantTmpFileManager *)->open(fd, dir, ""); std::cout << "open temporary file: " << fd << std::endl; ASSERT_EQ(OB_SUCCESS, ret); tmp_file::ObTmpFileHandle file_handle; @@ -431,7 +431,7 @@ TEST_F(TestTmpFile, test_cached_read) int64_t fd = -1; ret = MTL(ObTenantTmpFileManager *)->alloc_dir(dir); ASSERT_EQ(OB_SUCCESS, ret); - ret = MTL(ObTenantTmpFileManager *)->open(fd, dir); + ret = MTL(ObTenantTmpFileManager *)->open(fd, dir, ""); std::cout << "open temporary file: " << fd << std::endl; ASSERT_EQ(OB_SUCCESS, ret); tmp_file::ObTmpFileHandle file_handle; @@ -575,7 +575,7 @@ TEST_F(TestTmpFile, test_write_tail_page) int64_t fd = -1; ret = MTL(ObTenantTmpFileManager *)->alloc_dir(dir); ASSERT_EQ(OB_SUCCESS, ret); - ret = MTL(ObTenantTmpFileManager *)->open(fd, dir); + ret = MTL(ObTenantTmpFileManager *)->open(fd, dir, ""); std::cout << "open temporary file: " << fd << std::endl; ASSERT_EQ(OB_SUCCESS, ret); tmp_file::ObTmpFileHandle file_handle; @@ -733,7 +733,7 @@ TEST_F(TestTmpFile, test_tmp_file_truncate) int64_t fd = -1; ret = MTL(ObTenantTmpFileManager *)->alloc_dir(dir); ASSERT_EQ(OB_SUCCESS, ret); - ret = MTL(ObTenantTmpFileManager *)->open(fd, dir); + ret = MTL(ObTenantTmpFileManager *)->open(fd, dir, ""); std::cout << "open temporary file: " << fd << std::endl; ASSERT_EQ(OB_SUCCESS, ret); tmp_file::ObTmpFileHandle file_handle; @@ -1023,7 +1023,7 @@ TEST_F(TestTmpFile, test_truncate_to_flushed_page_id) int64_t fd = -1; ret = MTL(ObTenantTmpFileManager *)->alloc_dir(dir); ASSERT_EQ(OB_SUCCESS, ret); - ret = MTL(ObTenantTmpFileManager *)->open(fd, dir); + ret = MTL(ObTenantTmpFileManager *)->open(fd, dir, ""); std::cout << "open temporary file: " << fd << std::endl; ASSERT_EQ(OB_SUCCESS, ret); tmp_file::ObTmpFileHandle file_handle; @@ -1137,7 +1137,7 @@ TEST_F(TestTmpFile, test_write_last_page_during_flush) int64_t fd = -1; ret = MTL(ObTenantTmpFileManager *)->alloc_dir(dir); ASSERT_EQ(OB_SUCCESS, ret); - ret = MTL(ObTenantTmpFileManager *)->open(fd, dir); + ret = MTL(ObTenantTmpFileManager *)->open(fd, dir, ""); std::cout << "open temporary file: " << fd << std::endl; ASSERT_EQ(OB_SUCCESS, ret); tmp_file::ObTmpFileHandle file_handle; @@ -1221,7 +1221,7 @@ void test_big_file(const int64_t write_size, const int64_t wbp_mem_limit, ObTmpF int64_t fd = -1; ret = MTL(ObTenantTmpFileManager *)->alloc_dir(dir); ASSERT_EQ(OB_SUCCESS, ret); - ret = MTL(ObTenantTmpFileManager *)->open(fd, dir); + ret = MTL(ObTenantTmpFileManager *)->open(fd, dir, ""); std::cout << "open temporary file: " << fd << " tenant_id:"<< MTL_ID() << std::endl; ASSERT_EQ(OB_SUCCESS, ret); tmp_file::ObTmpFileHandle file_handle; @@ -1351,7 +1351,7 @@ void test_multi_file_single_thread_read_write(bool disable_block_cache) for (int i = 0; i < file_num; ++i) { int64_t dir = i % 2 == 0 ? dir1 : dir2; int64_t fd = -1; - ret = MTL(ObTenantTmpFileManager *)->open(fd, dir); + ret = MTL(ObTenantTmpFileManager *)->open(fd, dir, ""); std::cout << "open temporary file: " << fd << std::endl; ASSERT_EQ(OB_SUCCESS, ret); fds[i] = fd; @@ -1664,7 +1664,7 @@ TEST_F(TestTmpFile, test_aio_pread) int64_t fd = -1; ret = MTL(ObTenantTmpFileManager *)->alloc_dir(dir); ASSERT_EQ(OB_SUCCESS, ret); - ret = MTL(ObTenantTmpFileManager *)->open(fd, dir); + ret = MTL(ObTenantTmpFileManager *)->open(fd, dir, ""); std::cout << "open temporary file: " << fd << std::endl; ASSERT_EQ(OB_SUCCESS, ret); tmp_file::ObTmpFileHandle file_handle; diff --git a/mittest/mtlenv/storage/tmp_file/test_tmp_file_flush_list.cpp b/mittest/mtlenv/storage/tmp_file/test_tmp_file_flush_list.cpp index a29c2ea42..c833f29c3 100644 --- a/mittest/mtlenv/storage/tmp_file/test_tmp_file_flush_list.cpp +++ b/mittest/mtlenv/storage/tmp_file/test_tmp_file_flush_list.cpp @@ -262,7 +262,7 @@ TEST_F(TestFlushListIterator, test_iter_order) for (auto &mock_record: array) { int64_t fd = -1; int64_t dir = mock_record.dir; - ret = MTL(ObTenantTmpFileManager *)->open(fd, dir); + ret = MTL(ObTenantTmpFileManager *)->open(fd, dir, ""); ASSERT_EQ(OB_SUCCESS, ret); mock_dirty_record_[fd] = mock_record; diff --git a/src/storage/tmp_file/ob_tmp_file_flush_manager.cpp b/src/storage/tmp_file/ob_tmp_file_flush_manager.cpp index ef74917d4..86ab93abe 100644 --- a/src/storage/tmp_file/ob_tmp_file_flush_manager.cpp +++ b/src/storage/tmp_file/ob_tmp_file_flush_manager.cpp @@ -693,6 +693,8 @@ int ObTmpFileFlushManager::drive_flush_task_retry_( FlushState &next_state) { int ret = OB_SUCCESS; + int tmp_ret = OB_SUCCESS; + next_state = state; switch (state) { case FlushState::TFFT_INSERT_META_TREE: @@ -705,6 +707,10 @@ int ObTmpFileFlushManager::drive_flush_task_retry_( if (0 == flush_task.get_flush_infos().count()) { STORAGE_LOG(INFO, "all flush info is aborted", KR(ret), K(flush_task)); next_state = FlushState::TFFT_ABORT; + if (OB_TMP_FAIL(tmp_file_block_mgr_.write_back_failed(flush_task.get_block_index()))) { + STORAGE_LOG(ERROR, "fail to notify tmp file block write back failed", + KR(ret), KR(tmp_ret), K(flush_task)); + } } else if (OB_FAIL(handle_async_write_(flush_task, next_state))) { STORAGE_LOG(WARN, "fail to handle flush task async write", KR(ret), K(flush_task)); } diff --git a/src/storage/tmp_file/ob_tmp_file_manager.cpp b/src/storage/tmp_file/ob_tmp_file_manager.cpp index 4205065b1..2292f2ba2 100644 --- a/src/storage/tmp_file/ob_tmp_file_manager.cpp +++ b/src/storage/tmp_file/ob_tmp_file_manager.cpp @@ -414,7 +414,10 @@ int ObTenantTmpFileManagerWithMTLSwitch::alloc_dir(const uint64_t tenant_id, int return ret; } -int ObTenantTmpFileManagerWithMTLSwitch::open(const uint64_t tenant_id, int64_t &fd, const int64_t &dir_id) +int ObTenantTmpFileManagerWithMTLSwitch::open(const uint64_t tenant_id, + int64_t &fd, + const int64_t &dir_id, + const char* const label) { int ret = OB_SUCCESS; if (OB_UNLIKELY(!is_valid_tenant_id(tenant_id) || is_virtual_tenant_id(tenant_id))) { @@ -432,8 +435,8 @@ int ObTenantTmpFileManagerWithMTLSwitch::open(const uint64_t tenant_id, int64_t } else if (OB_ISNULL(tmp_file_mgr)) { ret = OB_ERR_UNEXPECTED; LOG_ERROR("tmp file manager is null", KR(ret), K(tenant_id)); - } else if (OB_FAIL(tmp_file_mgr->open(fd, dir_id))) { - LOG_WARN("fail to open", KR(ret), K(tenant_id)); + } else if (OB_FAIL(tmp_file_mgr->open(fd, dir_id, label))) { + LOG_WARN("fail to open", KR(ret), K(tenant_id), K(fd), K(dir_id), KP(label)); } } return ret; diff --git a/src/storage/tmp_file/ob_tmp_file_manager.h b/src/storage/tmp_file/ob_tmp_file_manager.h index 1f54127a8..83f21b438 100644 --- a/src/storage/tmp_file/ob_tmp_file_manager.h +++ b/src/storage/tmp_file/ob_tmp_file_manager.h @@ -38,7 +38,7 @@ public: void destroy(); int alloc_dir(int64_t &dir_id); - int open(int64_t &fd, const int64_t &dir_id, const char* const label = nullptr); + int open(int64_t &fd, const int64_t &dir_id, const char* const label); int remove(const int64_t fd); public: @@ -71,7 +71,10 @@ class ObTenantTmpFileManagerWithMTLSwitch final public: static ObTenantTmpFileManagerWithMTLSwitch &get_instance(); int alloc_dir(const uint64_t tenant_id, int64_t &dir_id); - int open(const uint64_t tenant_id, int64_t &fd, const int64_t &dir_id); + int open(const uint64_t tenant_id, + int64_t &fd, + const int64_t &dir_id, + const char* const label = nullptr); int remove(const uint64_t tenant_id, const int64_t fd); public: