Skip to content

Commit

Permalink
address some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
shosseinimotlagh committed Oct 18, 2024
1 parent 96c9cff commit 10d4693
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/include/homestore/index/index_table.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,8 @@ class IndexTable : public IndexTableBase, public Btree< K, V > {

btree_status_t repair_links(BtreeNodePtr const& parent_node, void* cp_ctx) {
BT_LOG(DEBUG, "Repairing links for parent node {}", parent_node->to_string());

// Get the last key in the node
// TODO: is it possible that repairing many nodes causes an increase to level of btree? If so, then this needs
// to be handled. Get the last key in the node
auto const last_parent_key = parent_node->get_last_key< K >();
auto const is_parent_edge_node = parent_node->has_valid_edge();
if ((parent_node->total_entries() == 0) && !is_parent_edge_node) {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/common/crash_simulator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ class CrashSimulator {
sisl::urcu_scoped_ptr< bool > m_crashed;
};
} // namespace homestore
#endif
#endif
2 changes: 2 additions & 0 deletions src/lib/index/index_cp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ void IndexCPContext::to_string_dot(const std::string& filename) {
file.close();
LOGINFO("cp dag is stored in file {}", filename);
}

uint16_t IndexCPContext::num_dags() {
// count number of buffers whose up_buffers are nullptr
uint16_t count = 0;
Expand All @@ -153,6 +154,7 @@ uint16_t IndexCPContext::num_dags() {
});
return count;
}

std::string IndexCPContext::to_string_with_dags() {
struct DagNode {
IndexBufferPtr buf;
Expand Down
21 changes: 8 additions & 13 deletions src/lib/index/wb_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ void IndexWBCache::recover(sisl::byte_view sb) {
#ifdef _PRERELEASE
std::string log = fmt::format("\trecovering bufs (#of bufs = {}) before processing them\n", bufs.size());
for (auto const& [_, buf] : bufs) {
laod_buf(buf);
load_buf(buf);
fmt::format_to(std::back_inserter(log), "{}\n", buf->to_string());
}
LOGTRACEMOD(wbcache, "\n{}", log);
Expand Down Expand Up @@ -629,7 +629,7 @@ bool IndexWBCache::was_node_committed(IndexBufferPtr const& buf) {
}

// All down_buf has indicated that they have seen this up buffer, now its time to repair them.
laod_buf(buf);
load_buf(buf);
if (!BtreeNode::is_valid_node(sisl::blob{buf->m_bytes, m_node_size})) { return false; }
return (buf->m_dirtied_cp_id == cp_mgr().cp_guard()->id());
}
Expand Down Expand Up @@ -693,7 +693,7 @@ folly::Future< bool > IndexWBCache::async_cp_flush(IndexCPContext* cp_ctx) {

void IndexWBCache::do_flush_one_buf(IndexCPContext* cp_ctx, IndexBufferPtr const& buf, bool part_of_batch) {
#ifdef _PRERELEASE
static bool print_once = false;
static std::once_flag flag;
if (buf->m_crash_flag_on) {
std::string filename = "crash_buf_" + std::to_string(cp_ctx->id()) + ".dot";
LOGINFO("\nSimulating crash while writing buffer {}, stored in file {}", buf->to_string(), filename);
Expand All @@ -702,10 +702,7 @@ void IndexWBCache::do_flush_one_buf(IndexCPContext* cp_ctx, IndexBufferPtr const
cp_ctx->complete(true);
return;
} else if (hs()->crash_simulator().is_crashed()) {
if (!print_once) {
LOGINFO("crash simulation is ongoing, aid simulation by not flushing");
print_once = true;
}
std::call_once(flag, []() { LOGINFO("Crash simulation is ongoing; aid simulation by not flushing."); });
return;
}
#endif
Expand All @@ -730,7 +727,7 @@ void IndexWBCache::do_flush_one_buf(IndexCPContext* cp_ctx, IndexBufferPtr const
auto& pthis = s_cast< IndexWBCache& >(wb_cache());
pthis.process_write_completion(cp_ctx, buf);
} catch (const std::runtime_error& e) {
LOGTRACEMOD(wbcache, "Failed to access write-back cache: {}", e.what());
LLOGERROR("Failed to access write-back cache: {}", e.what());
}
});

Expand All @@ -740,12 +737,10 @@ void IndexWBCache::do_flush_one_buf(IndexCPContext* cp_ctx, IndexBufferPtr const

void IndexWBCache::process_write_completion(IndexCPContext* cp_ctx, IndexBufferPtr const& buf) {
#ifdef _PRERELEASE
static bool print_once = false;
static std::once_flag flag;
if (hs()->crash_simulator().is_crashed()) {
if (!print_once) {
LOGINFOMOD(wbcache, "Crash simulation is ongoing, ignore all process_write_completion");
print_once = true;
}
std::call_once(
flag, []() { LOGINFOMOD(wbcache, "Crash simulation is ongoing, ignore all process_write_completion"); });
return;
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/lib/index/wb_cache.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,6 @@ class IndexWBCache : public IndexWBCacheBase {

void recover_buf(IndexBufferPtr const& buf);
bool was_node_committed(IndexBufferPtr const& buf);
void laod_buf(IndexBufferPtr const& buf);
void load_buf(IndexBufferPtr const& buf);
};
} // namespace homestore

0 comments on commit 10d4693

Please sign in to comment.