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

Make leader to delete the raft repl dev in UT. #500

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.45"
version = "6.4.46"

homepage = "https://github.com/eBay/Homestore"
description = "HomeStore Storage Engine"
Expand Down
8 changes: 4 additions & 4 deletions src/lib/replication/repl_dev/raft_repl_dev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,20 +230,20 @@ void RaftReplDev::push_data_to_all_followers(repl_req_ptr_t rreq, sisl::sg_list
flatbuffers::FlatBufferToString(builder.GetBufferPointer() + sizeof(flatbuffers::uoffset_t),
PushDataRequestTypeTable()));*/

RD_LOGD("Data Channel: Pushing data to all followers: rreq=[{}]", rreq->to_compact_string());
RD_LOGD("Data Channel: Pushing data to all followers: rreq=[{}]", rreq->to_string());

group_msg_service()
->data_service_request_unidirectional(nuraft_mesg::role_regex::ALL, PUSH_DATA, rreq->m_pkts)
.via(&folly::InlineExecutor::instance())
.thenValue([this, rreq = std::move(rreq)](auto e) {
if (e.hasError()) {
RD_LOGE("Data Channel: Error in pushing data to all followers: rreq=[{}] error={}",
rreq->to_compact_string(), e.error());
RD_LOGE("Data Channel: Error in pushing data to all followers: rreq=[{}] error={}", rreq->to_string(),
e.error());
handle_error(rreq, RaftReplService::to_repl_error(e.error()));
return;
}
// Release the buffer which holds the packets
RD_LOGD("Data Channel: Data push completed for rreq=[{}]", rreq->to_compact_string());
RD_LOGD("Data Channel: Data push completed for rreq=[{}]", rreq->to_string());
rreq->release_fb_builder();
rreq->m_pkts.clear();
});
Expand Down
5 changes: 5 additions & 0 deletions src/lib/replication/service/raft_repl_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*********************************************************************************/
#include <sisl/logging/logging.h>
#include <iomgr/io_environment.hpp>
#include <iomgr/iomgr_flip.hpp>
#include <chrono>

#include <boost/uuid/string_generator.hpp>
Expand Down Expand Up @@ -118,6 +119,7 @@ void RaftReplService::start() {
// We need to first load the repl_dev with its config and then attach the raft config to that repl dev.
for (auto const& [buf, mblk] : m_config_sb_bufs) {
auto rdev = raft_group_config_found(buf, voidptr_cast(mblk));
if (!rdev) { continue; }
rdev->on_restart();
}
m_config_sb_bufs.clear();
Expand Down Expand Up @@ -342,6 +344,9 @@ void RaftReplService::start_reaper_thread() {
HS_DYNAMIC_CONFIG(generic.repl_dev_cleanup_interval_sec) * 1000 * 1000 * 1000, true /* recurring */,
nullptr, [this](void*) {
gc_repl_reqs();
#ifdef _PRERELEASE
if (iomgr_flip::instance()->test_flip("disable_periodic_gc_repl_dev")) { return; }
#endif
gc_repl_devs();
});

Expand Down
13 changes: 7 additions & 6 deletions src/tests/test_raft_repl_dev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,11 @@ class RaftReplDevTest : public testing::Test {
});
}

if (g_helper->replica_num() == 0) {
// Leader sleeps here because follower-1 needs some time to find the leader after restart.
std::this_thread::sleep_for(std::chrono::seconds(5));
}

for (auto const& db : dbs_) {
if (db->is_zombie()) { continue; }
auto repl_dev = std::dynamic_pointer_cast< RaftReplDev >(db->repl_dev());
Expand Down Expand Up @@ -767,6 +772,7 @@ TEST_F(RaftReplDevTest, Snapshot_and_Compact) {

TEST_F(RaftReplDevTest, RemoveReplDev) {
LOGINFO("Homestore replica={} setup completed", g_helper->replica_num());
g_helper->set_basic_flip("disable_periodic_gc_repl_dev");

// Step 1: Create 2 more repldevs
LOGINFO("Create 2 more ReplDevs");
Expand Down Expand Up @@ -806,11 +812,6 @@ TEST_F(RaftReplDevTest, RemoveReplDev) {
LOGINFO("Remove last replica={} num_db={}", g_helper->replica_num(), dbs_.size());
}

if (g_helper->replica_num() == 0) {
// Leader sleeps here because follower-1 needs some time to find the leader after restart.
std::this_thread::sleep_for(std::chrono::seconds(20));
}

// TODO: Once generic crash flip/test_infra is available, use flip to crash during removal and restart them to
// see if records are being removed
g_helper->sync_for_cleanup_start();
Expand Down Expand Up @@ -944,7 +945,7 @@ int main(int argc, char* argv[]) {
//
HS_SETTINGS_FACTORY().modifiable_settings([](auto& s) {
s.consensus.leadership_expiry_ms = -1; // -1 means never expires;
s.generic.repl_dev_cleanup_interval_sec = 1;
s.generic.repl_dev_cleanup_interval_sec = 0;

// Disable implicit flush and timer.
s.logstore.flush_threshold_size = 0;
Expand Down
Loading