Skip to content

Commit

Permalink
Possible fix for refresh node lock problem (#330)
Browse files Browse the repository at this point in the history
  • Loading branch information
shosseinimotlagh authored Feb 28, 2024
1 parent 13e235d commit e0cd9a8
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .jenkins/jenkinsfile_nightly
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pipeline {
}
stage("Build") {
steps {
sh "conan create --build missing -o sisl:prerelease=True -o homestore:sanitize=True -o homestore:skip_testing=True -pr debug . ${PROJECT}/${VER}@"
sh "conan create --build missing -o homestore:sanitize=True -o homestore:skip_testing=True -pr debug . ${PROJECT}/${VER}@"
sh "find ${CONAN_USER_HOME} -type f -wholename '*bin/test_index_btree' -exec cp {} .jenkins/test_index_btree \\;"
sh "find ${CONAN_USER_HOME} -type f -wholename '*bin/test_meta_blk_mgr' -exec cp {} .jenkins/test_meta_blk_mgr \\;"
sh "find ${CONAN_USER_HOME} -type f -wholename '*bin/test_log_store' -exec cp {} .jenkins/test_log_store \\;"
Expand Down
2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class HomestoreConan(ConanFile):
name = "homestore"
version = "5.1.7"
version = "5.1.9"

homepage = "https://github.com/eBay/Homestore"
description = "HomeStore Storage Engine"
Expand Down
26 changes: 20 additions & 6 deletions src/include/homestore/index/index_table.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,30 @@ class IndexTable : public IndexTableBase, public Btree< K, V > {

template < typename ReqT >
btree_status_t put(ReqT& put_req) {
auto cpg = hs()->cp_mgr().cp_guard();
put_req.m_op_context = (void*)cpg.context(cp_consumer_t::INDEX_SVC);
return Btree< K, V >::put(put_req);
auto ret = btree_status_t::success;
do {
auto cpg = hs()->cp_mgr().cp_guard();
put_req.m_op_context = (void*)cpg.context(cp_consumer_t::INDEX_SVC);
ret = Btree< K, V >::put(put_req);
if (ret == btree_status_t::cp_mismatch) {
LOGTRACEMOD(wbcache, "CP Mismatch, retrying put");
}
} while (ret == btree_status_t::cp_mismatch);
return ret;
}

template < typename ReqT >
btree_status_t remove(ReqT& remove_req) {
auto cpg = hs()->cp_mgr().cp_guard();
remove_req.m_op_context = (void*)cpg.context(cp_consumer_t::INDEX_SVC);
return Btree< K, V >::remove(remove_req);
auto ret = btree_status_t::success;
do {
auto cpg = hs()->cp_mgr().cp_guard();
remove_req.m_op_context = (void*)cpg.context(cp_consumer_t::INDEX_SVC);
ret = Btree< K, V >::remove(remove_req);
if (ret == btree_status_t::cp_mismatch) {
LOGTRACEMOD(wbcache, "CP Mismatch, retrying remove");
}
} while (ret == btree_status_t::cp_mismatch);
return ret;
}

protected:
Expand Down
8 changes: 4 additions & 4 deletions src/tests/btree_helpers/btree_decls.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ struct VarKeySizeBtree {
};

struct VarValueSizeBtree {
using BtreeType = IndexTable< TestVarLenKey, TestVarLenValue >;
using KeyType = TestVarLenKey;
using BtreeType = IndexTable< TestFixedKey, TestVarLenValue >;
using KeyType = TestFixedKey;
using ValueType = TestVarLenValue;
static constexpr btree_node_type leaf_node_type = btree_node_type::VAR_OBJECT;
static constexpr btree_node_type interior_node_type = btree_node_type::VAR_OBJECT;
static constexpr btree_node_type leaf_node_type = btree_node_type::VAR_VALUE;
static constexpr btree_node_type interior_node_type = btree_node_type::FIXED;
};

struct VarObjSizeBtree {
Expand Down
52 changes: 41 additions & 11 deletions src/tests/btree_helpers/btree_test_helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,44 @@ struct BtreeTestHelper {
for (std::size_t i = 0; i < n_fibers; ++i) {
const auto start_range = i * chunk_size;
const auto end_range = start_range + ((i == n_fibers - 1) ? last_chunk_size : chunk_size);
iomanager.run_on_forget(m_fibers[i], [this, start_range, end_range, &test_count]() {
for (uint32_t i = start_range; i < end_range; i++) {
put(i, btree_put_type::INSERT);
}
{
std::unique_lock lg(m_test_done_mtx);
if (--test_count == 0) { m_test_done_cv.notify_one(); }
}
});
auto fiber_id = i;
iomanager.run_on_forget(
m_fibers[i], [this, start_range, end_range, &test_count, fiber_id, preload_size]() {
double progress_interval =
(double)(end_range - start_range) / 20; // 5% of the total number of iterations
double progress_thresh = progress_interval; // threshold for progress interval
double elapsed_time, progress_percent, last_progress_time = 0;
auto m_start_time = Clock::now();

for (uint32_t i = start_range; i < end_range; i++) {
put(i, btree_put_type::INSERT);
if (fiber_id == 0) {
elapsed_time = get_elapsed_time_sec(m_start_time);
progress_percent = (double)(i - start_range) / (end_range - start_range) * 100;

// check progress every 5% of the total number of iterations or every 30 seconds
bool print_time = false;
if (i >= progress_thresh) {
progress_thresh += progress_interval;
print_time = true;
}
if (elapsed_time - last_progress_time > 30) {
last_progress_time = elapsed_time;
print_time = true;
}
if (print_time) {
LOGINFO("Progress: iterations completed ({:.2f}%)- Elapsed time: {:.0f} seconds- "
"populated entries: {} ({:.2f}%)",
progress_percent, elapsed_time, m_shadow_map.size(),
m_shadow_map.size() * 100.0 / preload_size);
}
}
}
{
std::unique_lock lg(m_test_done_mtx);
if (--test_count == 0) { m_test_done_cv.notify_one(); }
}
});
}

{
Expand Down Expand Up @@ -419,8 +448,9 @@ struct BtreeTestHelper {
}
if (print_time) {
LOGINFO("Progress: iterations completed ({:.2f}%)- Elapsed time: {:.0f} seconds of total "
"{} - total entries: {}",
progress_percent, elapsed_time, m_run_time, m_shadow_map.size());
"{} ({:.2f}%) - total entries: {} ({:.2f}%)",
progress_percent, elapsed_time, m_run_time, elapsed_time * 100.0 / m_run_time,
m_shadow_map.size(), m_shadow_map.size() * 100.0 / m_max_range_input);
}
}
}
Expand Down

0 comments on commit e0cd9a8

Please sign in to comment.