From cbe45efac1b5f761a136803469d4067237d1d932 Mon Sep 17 00:00:00 2001 From: Sanal Date: Wed, 24 Apr 2024 17:29:23 -0700 Subject: [PATCH] Disable resource mgr truncation timer in logstore and logdev tests. (#391) --- conanfile.py | 2 +- src/lib/common/resource_mgr.cpp | 6 +++++- src/lib/common/resource_mgr.hpp | 2 +- src/lib/logstore/log_dev.cpp | 9 +++++---- src/tests/test_log_dev.cpp | 21 +++++++-------------- src/tests/test_log_store.cpp | 3 ++- 6 files changed, 21 insertions(+), 22 deletions(-) diff --git a/conanfile.py b/conanfile.py index e6c915935..6d903c5fd 100644 --- a/conanfile.py +++ b/conanfile.py @@ -5,7 +5,7 @@ class HomestoreConan(ConanFile): name = "homestore" - version = "6.3.3" + version = "6.3.4" homepage = "https://github.com/eBay/Homestore" description = "HomeStore Storage Engine" diff --git a/src/lib/common/resource_mgr.cpp b/src/lib/common/resource_mgr.cpp index 482d60549..a4276529b 100644 --- a/src/lib/common/resource_mgr.cpp +++ b/src/lib/common/resource_mgr.cpp @@ -31,7 +31,7 @@ void ResourceMgr::start(uint64_t total_cap) { void ResourceMgr::stop() { LOGINFO("Cancel resource manager timer."); - iomanager.cancel_timer(m_res_audit_timer_hdl); + if (m_res_audit_timer_hdl != iomgr::null_timer_handle) { iomanager.cancel_timer(m_res_audit_timer_hdl); } m_res_audit_timer_hdl = iomgr::null_timer_handle; } @@ -66,6 +66,10 @@ void ResourceMgr::trigger_truncate() { void ResourceMgr::start_timer() { auto const res_mgr_timer_ms = HS_DYNAMIC_CONFIG(resource_limits.resource_audit_timer_ms); LOGINFO("resource audit timer is set to {} usec", res_mgr_timer_ms); + if (res_mgr_timer_ms == 0) { + LOGINFO("resource audit timer is set to 0, so not starting timer"); + return; + } m_res_audit_timer_hdl = iomanager.schedule_global_timer( res_mgr_timer_ms * 1000 * 1000, true /* recurring */, nullptr /* cookie */, iomgr::reactor_regex::all_worker, diff --git a/src/lib/common/resource_mgr.hpp b/src/lib/common/resource_mgr.hpp index 9d4cb10ea..4bdcd4478 100644 --- a/src/lib/common/resource_mgr.hpp +++ b/src/lib/common/resource_mgr.hpp @@ -151,7 +151,7 @@ class ResourceMgr { exceed_limit_cb_t m_journal_vdev_exceed_cb; RsrcMgrMetrics m_metrics; - iomgr::timer_handle_t m_res_audit_timer_hdl; + iomgr::timer_handle_t m_res_audit_timer_hdl{iomgr::null_timer_handle}; }; extern ResourceMgr& resource_mgr(); diff --git a/src/lib/logstore/log_dev.cpp b/src/lib/logstore/log_dev.cpp index cb2813543..88e98f915 100644 --- a/src/lib/logstore/log_dev.cpp +++ b/src/lib/logstore/log_dev.cpp @@ -514,11 +514,12 @@ bool LogDev::run_under_flush_lock(const flush_blocked_callback& cb) { void LogDev::unlock_flush(bool do_flush) { std::vector< flush_blocked_callback >* flush_q{nullptr}; - - if (m_block_flush_q != nullptr) { + { std::unique_lock lk{m_block_flush_q_mutex}; - flush_q = m_block_flush_q; - m_block_flush_q = nullptr; + if (m_block_flush_q != nullptr) { + flush_q = m_block_flush_q; + m_block_flush_q = nullptr; + } } if (flush_q) { diff --git a/src/tests/test_log_dev.cpp b/src/tests/test_log_dev.cpp index d56af0303..c876fd6ac 100644 --- a/src/tests/test_log_dev.cpp +++ b/src/tests/test_log_dev.cpp @@ -77,15 +77,13 @@ class LogDevTest : public ::testing::Test { void start_homestore(bool restart = false, hs_before_services_starting_cb_t starting_cb = nullptr) { auto const ndevices = SISL_OPTIONS["num_devs"].as< uint32_t >(); auto const dev_size = SISL_OPTIONS["dev_size_mb"].as< uint64_t >() * 1024 * 1024; - if (starting_cb == nullptr) { - starting_cb = [this]() { - HS_SETTINGS_FACTORY().modifiable_settings([](auto& s) { - // Disable flush timer in UT. - s.logstore.flush_timer_frequency_us = 0; - }); - HS_SETTINGS_FACTORY().save(); - }; - } + HS_SETTINGS_FACTORY().modifiable_settings([](auto& s) { + // Disable flush timer in UT. + s.logstore.flush_timer_frequency_us = 0; + s.resource_limits.resource_audit_timer_ms = 0; + }); + HS_SETTINGS_FACTORY().save(); + test_common::HSTestHelper::start_homestore("test_log_dev", { {HS_SERVICE::META, {.size_pct = 15.0}}, @@ -284,11 +282,6 @@ TEST_F(LogDevTest, Rollback) { auto restart = [&]() { std::promise< bool > p; auto starting_cb = [&]() { - HS_SETTINGS_FACTORY().modifiable_settings([](auto& s) { - // Disable flush timer in UT. - s.logstore.flush_timer_frequency_us = 0; - }); - HS_SETTINGS_FACTORY().save(); logstore_service().open_logdev(logdev_id); logstore_service().open_log_store(logdev_id, store_id, false /* append_mode */).thenValue([&](auto store) { log_store = store; diff --git a/src/tests/test_log_store.cpp b/src/tests/test_log_store.cpp index 7d197e5e8..fd103ef47 100644 --- a/src/tests/test_log_store.cpp +++ b/src/tests/test_log_store.cpp @@ -484,8 +484,9 @@ class SampleDB { {HS_SERVICE::LOG, {.size_pct = 84.0, .chunk_size = 8 * 1024 * 1024, .min_chunk_size = 8 * 1024 * 1024}}}, [this, restart, n_log_stores]() { HS_SETTINGS_FACTORY().modifiable_settings([](auto& s) { - // Disable flush timer in UT. + // Disable flush and resource mgr timer in UT. s.logstore.flush_timer_frequency_us = 0; + s.resource_limits.resource_audit_timer_ms = 0; }); HS_SETTINGS_FACTORY().save();