Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Index crash recovery test cases and fixes #458

Merged
merged 8 commits into from
Aug 2, 2024
7 changes: 5 additions & 2 deletions src/lib/index/index_cp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,11 @@ void IndexCPContext::process_txn_record(txn_record const* rec, std::map< BlkId,
if (found) { return buf; }
real_up_buf->m_down_buffers.emplace_back(buf);
#endif
real_up_buf->m_wait_for_down_buffers.increment(1);
buf->m_up_buffer = real_up_buf;

if (buf->m_up_buffer != real_up_buf) {
real_up_buf->m_wait_for_down_buffers.increment(1);
buf->m_up_buffer = real_up_buf;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exactly

}
}
return buf;
};
Expand Down
20 changes: 11 additions & 9 deletions src/tests/test_index_crash_recovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,18 +137,20 @@ struct IndexCrashTest : public test_common::HSTestHelper, BtreeTestHelper< TestT
void reapply_after_crash() {
ShadowMap< K, V > snapshot_map{this->m_shadow_map.max_keys()};
snapshot_map.load(m_shadow_filename);
LOGINFO("\tSnapshot before crash\n{}", snapshot_map.to_string());
LOGDEBUG("\tSnapshot before crash\n{}", snapshot_map.to_string());
auto diff = this->m_shadow_map.diff(snapshot_map);

// visualize tree after crash
// std::string recovered_tree_filename = "tree_after_crash_" + to_string(rand() % 100) + ".dot";
// this->visualize_keys(recovered_tree_filename);
// LOGINFO(" tree after recovered stored in {}", recovered_tree_filename);

std::string dif_str = "KEY \tADDITION\n";
for (const auto& [k, addition] : diff) {
dif_str += fmt::format(" {} \t{}\n", k.key(), addition);
}
// visualize tree after crash
std::string recovered_tree_filename = "tree_after_crash_" + to_string(rand() % 100) + ".dot";
// this->visualize_keys(recovered_tree_filename);
LOGINFO(" tree after recovered stored in {}", recovered_tree_filename);
// test_common::HSTestHelper::trigger_cp(true);
LOGINFO("Diff between shadow map and snapshot map\n{}\n", dif_str);
LOGDEBUG("Diff between shadow map and snapshot map\n{}\n", dif_str);

for (const auto& [k, addition] : diff) {
// this->print_keys(fmt::format("reapply: before inserting key {}", k.key()));
// this->visualize_keys(recovered_tree_filename);
Expand Down Expand Up @@ -244,8 +246,8 @@ TYPED_TEST(IndexCrashTest, SplitOnLeftEdge) {
this->set_basic_flip("crash_flush_on_split_at_left_child");
this->visualize_keys("tree_before_insert.dot");
for (auto k = num_entries / 4; k < num_entries / 2; ++k) {
LOGINFO("inserting key {}", k);
this->visualize_keys("tree_before_" + to_string(k) + ".dot");
// LOGINFO("inserting key {}", k);
// this->visualize_keys("tree_before_" + to_string(k) + ".dot");
this->put(k, btree_put_type::INSERT, true /* expect_success */);
}
this->visualize_keys("tree_before_crash.dot");
Expand Down
Loading