diff --git a/.jenkins/Dockerfile b/.jenkins/Dockerfile index 1306f9140..d481ff641 100644 --- a/.jenkins/Dockerfile +++ b/.jenkins/Dockerfile @@ -15,6 +15,7 @@ RUN set -eux; \ COPY test_index_btree /usr/local/bin/test_index_btree COPY test_meta_blk_mgr /usr/local/bin/test_meta_blk_mgr COPY test_log_store /usr/local/bin/test_log_store +COPY test_home_raft_logstore /usr/local/bin/test_home_raft_logstore COPY test_log_store_long_run /usr/local/bin/test_log_store_long_run COPY test_data_service /usr/local/bin/test_data_service COPY test_raft_repl_dev /usr/local/bin/test_raft_repl_dev diff --git a/.jenkins/jenkinsfile_nightly b/.jenkins/jenkinsfile_nightly index 1af16b91a..7ef305257 100644 --- a/.jenkins/jenkinsfile_nightly +++ b/.jenkins/jenkinsfile_nightly @@ -44,6 +44,7 @@ pipeline { sh "find ${CONAN_USER_HOME} -type f -wholename '*tests/test_index_btree' -exec cp {} .jenkins/test_index_btree \\;" sh "find ${CONAN_USER_HOME} -type f -wholename '*tests/test_meta_blk_mgr' -exec cp {} .jenkins/test_meta_blk_mgr \\;" sh "find ${CONAN_USER_HOME} -type f -wholename '*tests/test_log_store' -exec cp {} .jenkins/test_log_store \\;" + sh "find ${CONAN_USER_HOME} -type f -wholename '*tests/test_home_raft_logstore' -exec cp {} .jenkins/test_home_raft_logstore \\;" sh "find ${CONAN_USER_HOME} -type f -wholename '*tests/test_log_store_long_run' -exec cp {} .jenkins/test_log_store_long_run \\;" sh "find ${CONAN_USER_HOME} -type f -wholename '*tests/test_data_service' -exec cp {} .jenkins/test_data_service \\;" sh "find ${CONAN_USER_HOME} -type f -wholename '*tests/test_raft_repl_dev' -exec cp {} .jenkins/test_raft_repl_dev \\;" diff --git a/conanfile.py b/conanfile.py index ca31ef1b6..c31e269b7 100644 --- a/conanfile.py +++ b/conanfile.py @@ -9,7 +9,7 @@ class HomestoreConan(ConanFile): name = "homestore" - version = "6.4.49" + version = "6.4.50" homepage = "https://github.com/eBay/Homestore" description = "HomeStore Storage Engine" diff --git a/src/lib/logstore/log_dev.cpp b/src/lib/logstore/log_dev.cpp index 507f02f19..5684eeda8 100644 --- a/src/lib/logstore/log_dev.cpp +++ b/src/lib/logstore/log_dev.cpp @@ -435,32 +435,36 @@ bool LogDev::flush() { return false; } - LogGroup* lg = prepare_flush(new_idx - m_last_flush_idx + 4); // Estimate 4 more extra in case of parallel writes - if (sisl_unlikely(!lg)) { - THIS_LOGDEV_LOG(TRACE, "Log idx {} last_flush_idx {} prepare flush failed", new_idx, m_last_flush_idx); - return false; - } - auto sz = m_pending_flush_size.fetch_sub(lg->actual_data_size(), std::memory_order_relaxed); - HS_REL_ASSERT_GE((sz - lg->actual_data_size()), 0, "size {} lg size {}", sz, lg->actual_data_size()); - off_t offset = m_vdev_jd->alloc_next_append_blk(lg->header()->total_size()); - lg->m_log_dev_offset = offset; - - HS_REL_ASSERT_NE(lg->m_log_dev_offset, INVALID_OFFSET, "log dev is full"); - THIS_LOGDEV_LOG(TRACE, "Flushing log group data size={} at offset={} log_group={}", lg->actual_data_size(), offset, - *lg); - - HISTOGRAM_OBSERVE(logstore_service().m_metrics, logdev_flush_records_distribution, lg->nrecords()); - HISTOGRAM_OBSERVE(logstore_service().m_metrics, logdev_flush_size_distribution, lg->actual_data_size()); + for (; m_last_flush_idx < new_idx;) { + LogGroup* lg = + prepare_flush(new_idx - m_last_flush_idx + 4); // Estimate 4 more extra in case of parallel writes + if (sisl_unlikely(!lg)) { + THIS_LOGDEV_LOG(TRACE, "Log idx {} last_flush_idx {} prepare flush failed", new_idx, m_last_flush_idx); + return false; + } + auto sz = m_pending_flush_size.fetch_sub(lg->actual_data_size(), std::memory_order_relaxed); + HS_REL_ASSERT_GE((sz - lg->actual_data_size()), 0, "size {} lg size {}", sz, lg->actual_data_size()); + off_t offset = m_vdev_jd->alloc_next_append_blk(lg->header()->total_size()); + lg->m_log_dev_offset = offset; + + HS_REL_ASSERT_NE(lg->m_log_dev_offset, INVALID_OFFSET, "log dev is full"); + THIS_LOGDEV_LOG(TRACE, "Flushing log group data size={} at offset={} log_group={}", lg->actual_data_size(), + offset, *lg); + + HISTOGRAM_OBSERVE(logstore_service().m_metrics, logdev_flush_records_distribution, lg->nrecords()); + HISTOGRAM_OBSERVE(logstore_service().m_metrics, logdev_flush_size_distribution, lg->actual_data_size()); + + // TODO:: add logic to handle this error in upper layer + auto error = m_vdev_jd->sync_pwritev(lg->iovecs().data(), int_cast(lg->iovecs().size()), lg->m_log_dev_offset); + if (error) { + THIS_LOGDEV_LOG(ERROR, "Fail to sync write to journal vde , error code {} : {}", error.value(), + error.message()); + return false; + } - // FIXME:: add logic to handle this error in upper layer - auto error = m_vdev_jd->sync_pwritev(lg->iovecs().data(), int_cast(lg->iovecs().size()), lg->m_log_dev_offset); - if (error) { - THIS_LOGDEV_LOG(ERROR, "Fail to sync write to journal vde , error code {} : {}", error.value(), - error.message()); - return false; + on_flush_completion(lg); } - on_flush_completion(lg); return true; } diff --git a/src/lib/logstore/log_store.cpp b/src/lib/logstore/log_store.cpp index 7c2fbe82f..e52b48b83 100644 --- a/src/lib/logstore/log_store.cpp +++ b/src/lib/logstore/log_store.cpp @@ -177,6 +177,7 @@ void HomeLogStore::on_log_found(logstore_seq_num_t seq_num, const logdev_key& ld void HomeLogStore::truncate(logstore_seq_num_t upto_lsn, bool in_memory_truncate_only) { if (upto_lsn < m_start_lsn) { return; } + flush(); #ifndef NDEBUG auto cs = get_contiguous_completed_seq_num(0); if (upto_lsn > cs) { diff --git a/src/lib/replication/log_store/home_raft_log_store.cpp b/src/lib/replication/log_store/home_raft_log_store.cpp index 6a589dc84..94fecbc18 100644 --- a/src/lib/replication/log_store/home_raft_log_store.cpp +++ b/src/lib/replication/log_store/home_raft_log_store.cpp @@ -321,20 +321,7 @@ bool HomeRaftLogStore::compact(ulong compact_lsn) { append(m_dummy_log_entry); } } - - m_log_store->flush(to_store_lsn(compact_lsn)); - - // this will only truncate in memory, and not on disk; - // we rely on resrouce mgr timer to trigger real truncate for all log stores in system; - // this will be friendly for multiple logstore on same logdev; -#ifdef _PRERELEASE - if (iomgr_flip::instance()->test_flip("force_home_raft_log_truncate")) { - REPL_STORE_LOG(TRACE, "Flip force_home_raft_log_truncate is enabled, force truncation, compact_lsn={}", - compact_lsn); - m_log_store->truncate(to_store_lsn(compact_lsn)); - } -#endif - + m_log_store->truncate(to_store_lsn(compact_lsn)); return true; } diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index eab66ece1..4f18d763a 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -122,11 +122,11 @@ if (${io_tests}) if(${epoll_tests}) add_test(NAME LogDev-Epoll COMMAND test_log_dev) add_test(NAME LogStore-Epoll COMMAND test_log_store) + add_test(NAME HomeRaftLogStore-Epoll COMMAND test_home_raft_logstore) add_test(NAME MetaBlkMgr-Epoll COMMAND test_meta_blk_mgr) add_test(NAME DataService-Epoll COMMAND test_data_service) # add_test(NAME SoloReplDev-Epoll COMMAND ${CMAKE_BINARY_DIR}/bin/test_solo_repl_dev) - # add_test(NAME HomeRaftLogStore-Epoll COMMAND ${CMAKE_BINARY_DIR}/bin/test_home_raft_logstore) # add_test(NAME RaftReplDev-Epoll COMMAND ${CMAKE_BINARY_DIR}/bin/test_raft_repl_dev) endif() diff --git a/src/tests/test_common/homestore_test_common.hpp b/src/tests/test_common/homestore_test_common.hpp index 3b5484966..44c257793 100644 --- a/src/tests/test_common/homestore_test_common.hpp +++ b/src/tests/test_common/homestore_test_common.hpp @@ -46,7 +46,7 @@ SISL_OPTION_GROUP( "number"), (num_devs, "", "num_devs", "number of devices to create", ::cxxopts::value< uint32_t >()->default_value("3"), "number"), - (dev_size_mb, "", "dev_size_mb", "size of each device in MB", ::cxxopts::value< uint64_t >()->default_value("1024"), + (dev_size_mb, "", "dev_size_mb", "size of each device in MB", ::cxxopts::value< uint64_t >()->default_value("2048"), "number"), (device_list, "", "device_list", "Device List instead of default created", ::cxxopts::value< std::vector< std::string > >(), "path [...]"),