Skip to content

Commit

Permalink
enable home raft log store UT
Browse files Browse the repository at this point in the history
  • Loading branch information
JacksonYao287 committed Aug 20, 2024
1 parent 314ee9a commit af5fa7d
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 40 deletions.
1 change: 1 addition & 0 deletions .jenkins/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .jenkins/jenkinsfile_nightly
Original file line number Diff line number Diff line change
Expand Up @@ -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 \\;"
Expand Down
2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
50 changes: 27 additions & 23 deletions src/lib/logstore/log_dev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions src/lib/logstore/log_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
15 changes: 1 addition & 14 deletions src/lib/replication/log_store/home_raft_log_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion src/tests/test_common/homestore_test_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 [...]"),
Expand Down

0 comments on commit af5fa7d

Please sign in to comment.