bugfix: temporary file normal reading mislead into direct reading logic.

This commit is contained in:
ND501
2024-02-05 13:42:21 +00:00
committed by ob-robot
parent 9d42f1c510
commit 3b2918c459
2 changed files with 38 additions and 8 deletions

View File

@ -124,17 +124,17 @@ int ObTmpPageCache::inner_read_io(const ObTmpBlockIOInfo &io_info,
ObMacroBlockHandle &macro_block_handle) ObMacroBlockHandle &macro_block_handle)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
if (OB_FAIL(read_io(io_info, nullptr, macro_block_handle))) { if (OB_FAIL(read_io(io_info, callback, macro_block_handle))) {
if (macro_block_handle.get_io_handle().is_empty()) { if (macro_block_handle.get_io_handle().is_empty()) {
// TODO: After the continuous IO has been optimized, this should // TODO: After the continuous IO has been optimized, this should
// not happen. // not happen.
if (OB_FAIL(macro_block_handle.wait())) { if (OB_FAIL(macro_block_handle.wait())) {
STORAGE_LOG(WARN, "fail to wait tmp page io", K(ret)); STORAGE_LOG(WARN, "fail to wait tmp page io", K(ret), KP(callback));
} else if (OB_FAIL(read_io(io_info, nullptr, macro_block_handle))) { } else if (OB_FAIL(read_io(io_info, callback, macro_block_handle))) {
STORAGE_LOG(WARN, "fail to read tmp page from io", K(ret)); STORAGE_LOG(WARN, "fail to read tmp page from io", K(ret), KP(callback));
} }
} else { } else {
STORAGE_LOG(WARN, "fail to read tmp page from io", K(ret)); STORAGE_LOG(WARN, "fail to read tmp page from io", K(ret), KP(callback));
} }
} }
// Avoid double_free with io_handle // Avoid double_free with io_handle
@ -391,12 +391,16 @@ int ObTmpPageCache::read_io(const ObTmpBlockIOInfo &io_info, ObITmpPageIOCallbac
read_info.io_desc_ = io_info.io_desc_; read_info.io_desc_ = io_info.io_desc_;
read_info.macro_block_id_ = io_info.macro_block_id_; read_info.macro_block_id_ = io_info.macro_block_id_;
read_info.io_timeout_ms_ = io_info.io_timeout_ms_; read_info.io_timeout_ms_ = io_info.io_timeout_ms_;
read_info.io_callback_ = callback; if (callback == nullptr) {
read_info.buf_ = io_info.buf_;
} else {
read_info.io_callback_ = callback;
}
read_info.offset_ = io_info.offset_; read_info.offset_ = io_info.offset_;
read_info.size_ = io_info.size_; read_info.size_ = io_info.size_;
read_info.io_desc_.set_group_id(ObIOModule::TMP_PAGE_CACHE_IO); read_info.io_desc_.set_group_id(ObIOModule::TMP_PAGE_CACHE_IO);
if (OB_FAIL(ObBlockManager::async_read_block(read_info, handle))) { if (OB_FAIL(ObBlockManager::async_read_block(read_info, handle))) {
STORAGE_LOG(WARN, "fail to async read block", K(ret), K(read_info)); STORAGE_LOG(WARN, "fail to async read block", K(ret), K(read_info), KP(callback));
} }
return ret; return ret;
} }

View File

@ -11,6 +11,8 @@
*/ */
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <signal.h>
#include <unistd.h>
#define protected public #define protected public
#define private public #define private public
#include "lib/allocator/ob_fifo_allocator.h" #include "lib/allocator/ob_fifo_allocator.h"
@ -635,6 +637,8 @@ void TestTmpFile::SetUp()
EXPECT_EQ(OB_SUCCESS, io_service->start()); EXPECT_EQ(OB_SUCCESS, io_service->start());
tenant_ctx.set(io_service); tenant_ctx.set(io_service);
ObTenantEnv::set_tenant(&tenant_ctx); ObTenantEnv::set_tenant(&tenant_ctx);
ObMallocAllocator::get_instance()->set_tenant_limit(1, 8L * 1024L * 1024L * 1024L /* 8 GB */);
} }
void TestTmpFile::TearDown() void TestTmpFile::TearDown()
@ -676,6 +680,8 @@ TEST_F(TestTmpFile, test_big_file)
write_time = ObTimeUtility::current_time() - write_time; write_time = ObTimeUtility::current_time() - write_time;
io_info.buf_ = read_buf; io_info.buf_ = read_buf;
ObKVGlobalCache::get_instance().erase_cache(1, "tmp_block_cache");
io_info.size_ = write_size; io_info.size_ = write_size;
ret = ObTmpFileManager::get_instance().aio_read(io_info, handle); ret = ObTmpFileManager::get_instance().aio_read(io_info, handle);
ASSERT_EQ(OB_SUCCESS, ret); ASSERT_EQ(OB_SUCCESS, ret);
@ -724,6 +730,7 @@ TEST_F(TestTmpFile, test_big_file)
ObTmpFileManager::get_instance().remove(fd); ObTmpFileManager::get_instance().remove(fd);
} }
/*
TEST_F(TestTmpFile, test_big_file_disable_page_cache) TEST_F(TestTmpFile, test_big_file_disable_page_cache)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
@ -755,6 +762,8 @@ TEST_F(TestTmpFile, test_big_file_disable_page_cache)
write_time = ObTimeUtility::current_time() - write_time; write_time = ObTimeUtility::current_time() - write_time;
io_info.buf_ = read_buf; io_info.buf_ = read_buf;
ObKVGlobalCache::get_instance().erase_cache(1, "tmp_block_cache");
io_info.size_ = write_size; io_info.size_ = write_size;
ret = ObTmpFileManager::get_instance().aio_read(io_info, handle); ret = ObTmpFileManager::get_instance().aio_read(io_info, handle);
ASSERT_EQ(OB_SUCCESS, ret); ASSERT_EQ(OB_SUCCESS, ret);
@ -790,7 +799,7 @@ TEST_F(TestTmpFile, test_big_file_disable_page_cache)
free(write_buf); free(write_buf);
free(read_buf); free(read_buf);
STORAGE_LOG(INFO, "test_big_file"); STORAGE_LOG(INFO, "test_big_file_disable_page_cache");
STORAGE_LOG(INFO, "io time", K(write_time), K(read_time)); STORAGE_LOG(INFO, "io time", K(write_time), K(read_time));
ObTmpTenantFileStoreHandle store_handle; ObTmpTenantFileStoreHandle store_handle;
OB_TMP_FILE_STORE.get_store(1, store_handle); OB_TMP_FILE_STORE.get_store(1, store_handle);
@ -802,6 +811,7 @@ TEST_F(TestTmpFile, test_big_file_disable_page_cache)
ObTmpFileManager::get_instance().remove(fd); ObTmpFileManager::get_instance().remove(fd);
} }
*/
TEST_F(TestTmpFile, test_multi_small_file_single_thread_read_write) TEST_F(TestTmpFile, test_multi_small_file_single_thread_read_write)
{ {
@ -2342,8 +2352,24 @@ TEST_F(TestTmpFile, test_truncate_free_block) {
} // end namespace unittest } // end namespace unittest
} // end namespace oceanbase } // end namespace oceanbase
void sig_49_handler(int signo)
{
// do nothing.
}
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
struct sigaction sa;
sa.sa_handler = sig_49_handler;
sa.sa_flags = 0;
sigemptyset(&sa.sa_mask);
// catch 49 signal and do nothing.
if (sigaction(49, &sa, NULL) == -1) {
perror("sigaction");
return 1;
}
system("rm -f test_tmp_file.log*"); system("rm -f test_tmp_file.log*");
oceanbase::common::ObLogger::get_logger().set_log_level("INFO"); oceanbase::common::ObLogger::get_logger().set_log_level("INFO");
OB_LOGGER.set_file_name("test_tmp_file.log", true, true); OB_LOGGER.set_file_name("test_tmp_file.log", true, true);