diff --git a/src/storage/tmp_file/ob_tmp_file_thread_wrapper.cpp b/src/storage/tmp_file/ob_tmp_file_thread_wrapper.cpp index 3ced7c027..9e7d2fa69 100644 --- a/src/storage/tmp_file/ob_tmp_file_thread_wrapper.cpp +++ b/src/storage/tmp_file/ob_tmp_file_thread_wrapper.cpp @@ -15,6 +15,7 @@ #include "storage/tmp_file/ob_tmp_file_thread_wrapper.h" #include "share/ob_thread_mgr.h" #include "storage/blocksstable/ob_block_manager.h" +#include "storage/meta_store/ob_server_storage_meta_service.h" #include "storage/tmp_file/ob_tmp_file_page_cache_controller.h" #include "storage/tmp_file/ob_sn_tmp_file_manager.h" @@ -243,7 +244,9 @@ int64_t ObTmpFileFlushTG::cal_idle_time() { int64_t idle_time = 0; int64_t dirty_page_percentage = wbp_.get_dirty_page_percentage(); - if (!wait_list_.is_empty() || !retry_list_.is_empty() || !finished_list_.is_empty() + if (OB_UNLIKELY(!SERVER_STORAGE_META_SERVICE.is_started())) { + idle_time = ObTmpFilePageCacheController::FLUSH_INTERVAL; + } else if (!wait_list_.is_empty() || !retry_list_.is_empty() || !finished_list_.is_empty() || ObTmpFileFlushManager::FLUSH_WATERMARK_F1 <= dirty_page_percentage) { idle_time = ObTmpFilePageCacheController::FLUSH_FAST_INTERVAL; } else if (RUNNING_MODE::FAST == mode_) { @@ -265,7 +268,11 @@ int ObTmpFileFlushTG::try_work() int64_t cur_time = ObTimeUtility::current_monotonic_time(); if (0 == last_flush_timestamp_ || cur_time - last_flush_timestamp_ >= cal_idle_time() * 1000) { - if (OB_FAIL(do_work_())) { + if (OB_UNLIKELY(!SERVER_STORAGE_META_SERVICE.is_started())) { + ret = OB_NOT_RUNNING; + LOG_INFO("ObTmpFileFlushTG does not work before server slog replay finished", + KR(ret), KPC(this)); + } else if (OB_FAIL(do_work_())) { STORAGE_LOG(WARN, "fail do flush", KR(ret), KPC(this)); } last_flush_timestamp_ = ObTimeUtility::current_monotonic_time(); @@ -874,7 +881,9 @@ void ObTmpFileSwapTG::notify_doing_swap() int64_t ObTmpFileSwapTG::cal_idle_time() { int64_t swap_idle_time = ObTmpFilePageCacheController::SWAP_INTERVAL; - if (ATOMIC_LOAD(&swap_job_num_) != 0 || ATOMIC_LOAD(&working_list_size_) != 0) { + if (OB_UNLIKELY(!SERVER_STORAGE_META_SERVICE.is_started())) { + swap_idle_time = ObTmpFilePageCacheController::SWAP_INTERVAL; + } else if (ATOMIC_LOAD(&swap_job_num_) != 0 || ATOMIC_LOAD(&working_list_size_) != 0) { if (flush_io_finished_round_ < flush_tg_ref_.get_flush_io_finished_round()) { swap_idle_time = 0; } else { diff --git a/unittest/sql/engine/basic/test_chunk_datum_store.cpp b/unittest/sql/engine/basic/test_chunk_datum_store.cpp index f6820c3c6..67eecfaf0 100644 --- a/unittest/sql/engine/basic/test_chunk_datum_store.cpp +++ b/unittest/sql/engine/basic/test_chunk_datum_store.cpp @@ -47,6 +47,7 @@ public: OB_SYS_TENANT_ID); ASSERT_EQ(OB_SUCCESS, ret); int s = (int)time(NULL); + SERVER_STORAGE_META_SERVICE.is_started_ = true; LOG_INFO("initial setup random seed", K(s)); srandom(s); } diff --git a/unittest/sql/engine/basic/test_chunk_row_store.cpp b/unittest/sql/engine/basic/test_chunk_row_store.cpp index 63688424e..c397aa83a 100644 --- a/unittest/sql/engine/basic/test_chunk_row_store.cpp +++ b/unittest/sql/engine/basic/test_chunk_row_store.cpp @@ -104,6 +104,7 @@ public: ASSERT_EQ(OB_SUCCESS, rs_.alloc_dir_id()); memset(str_buf_, 'z', BUF_SIZE); + SERVER_STORAGE_META_SERVICE.is_started_ = true; LOG_WARN("setup finished", K_(row)); } diff --git a/unittest/storage/direct_load/test_direct_load_data_block_writer.cpp b/unittest/storage/direct_load/test_direct_load_data_block_writer.cpp index 9713c7308..dfd80861d 100644 --- a/unittest/storage/direct_load/test_direct_load_data_block_writer.cpp +++ b/unittest/storage/direct_load/test_direct_load_data_block_writer.cpp @@ -205,6 +205,7 @@ void TestDataBlockWriter::SetUp() tenant_ctx.set(tf_mgr); ObTenantEnv::set_tenant(&tenant_ctx); + SERVER_STORAGE_META_SERVICE.is_started_ = true; } void TestDataBlockWriter::TearDown() diff --git a/unittest/storage/test_parallel_external_sort.cpp b/unittest/storage/test_parallel_external_sort.cpp index e91f55ab6..5469ed747 100644 --- a/unittest/storage/test_parallel_external_sort.cpp +++ b/unittest/storage/test_parallel_external_sort.cpp @@ -206,6 +206,7 @@ void TestParallelExternalSort::SetUp() tenant_ctx.set(tf_mgr); ObTenantEnv::set_tenant(&tenant_ctx); + SERVER_STORAGE_META_SERVICE.is_started_ = true; } void TestParallelExternalSort::TearDown()