Skip to content

Commit

Permalink
fix repl service (#284)
Browse files Browse the repository at this point in the history
  • Loading branch information
JacksonYao287 authored Feb 1, 2024
1 parent 42cdddb commit 4da2de4
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
3 changes: 1 addition & 2 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

class HomestoreConan(ConanFile):
name = "homestore"
version = "5.0.8"

version = "5.0.9"
homepage = "https://github.com/eBay/Homestore"
description = "HomeStore Storage Engine"
topics = ("ebay", "nublox")
Expand Down
6 changes: 3 additions & 3 deletions src/include/homestore/replication/repl_dev.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ class ReplDevListener {
public:
virtual ~ReplDevListener() = default;

void set_repl_dev(ReplDev* rdev) { m_repl_dev = rdev; }
virtual ReplDev* repl_dev() { return m_repl_dev; }
void set_repl_dev(shared< ReplDev > rdev) { m_repl_dev = rdev; }
shared< ReplDev > repl_dev() { return m_repl_dev.lock(); }

/// @brief Called when the log entry has been committed in the replica set.
///
Expand Down Expand Up @@ -184,7 +184,7 @@ class ReplDevListener {
virtual void on_replica_stop() = 0;

private:
ReplDev* m_repl_dev;
std::weak_ptr< ReplDev > m_repl_dev;
};

class ReplDev {
Expand Down
6 changes: 5 additions & 1 deletion src/lib/homestore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ bool HomeStore::start(const hs_input_params& input, hs_before_services_starting_
if (has_meta_service()) { m_meta_service = std::make_unique< MetaBlkService >(); }
if (has_index_service()) { m_index_service = std::make_unique< IndexService >(std::move(s_index_cbs)); }
if (has_repl_data_service()) {
m_repl_service = GenericReplService::create(std::move(s_repl_app));
m_log_service = std::make_unique< LogStoreService >();
m_data_service = std::make_unique< BlkDataService >(std::move(s_custom_chunk_selector));
} else {
Expand Down Expand Up @@ -195,6 +194,11 @@ void HomeStore::format_and_start(std::map< uint32_t, hs_format_params >&& format
}

void HomeStore::do_start() {
// when coming here:
// 1 if this is the first_time_boot, , the repl app already gets its uuid from upper layer
// 2 if this is not the first_time_boot, the repl app already gets its uuid from the metaservice
// now , we can safely initialize GenericReplService , which will get a correct uuid through get_my_repl_uuid()
if (has_repl_data_service()) m_repl_service = GenericReplService::create(std::move(s_repl_app));
const auto& inp_params = HomeStoreStaticConfig::instance().input;

uint64_t cache_size = resource_mgr().get_cache_size();
Expand Down
4 changes: 2 additions & 2 deletions src/lib/replication/service/generic_repl_svc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ AsyncReplResult< shared< ReplDev > > SoloReplService::create_repl_dev(group_id_t
auto rdev = std::make_shared< SoloReplDev >(std::move(rd_sb), false /* load_existing */);

auto listener = m_repl_app->create_repl_dev_listener(group_id);
listener->set_repl_dev(rdev.get());
listener->set_repl_dev(rdev);
rdev->attach_listener(std::move(listener));

{
Expand All @@ -133,7 +133,7 @@ void SoloReplService::load_repl_dev(sisl::byte_view const& buf, void* meta_cooki
auto rdev = std::make_shared< SoloReplDev >(std::move(rd_sb), true /* load_existing */);

auto listener = m_repl_app->create_repl_dev_listener(group_id);
listener->set_repl_dev(rdev.get());
listener->set_repl_dev(rdev);
rdev->attach_listener(std::move(listener));

{
Expand Down
8 changes: 4 additions & 4 deletions src/lib/replication/service/raft_repl_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ void RaftReplService::start() {
.token_client_ = std::dynamic_pointer_cast< sisl::GrpcTokenClient >(ioenvironment.get_token_client())};
m_msg_mgr = nuraft_mesg::init_messaging(params, weak_from_this(), true /* with_data_channel */);

LOGINFOMOD(replication, "Starting RaftReplService with server_uuid={} port={}",
boost::uuids::to_string(params.server_uuid_), params.mesg_port_);
LOGINFO("Starting RaftReplService with server_uuid={} port={}", boost::uuids::to_string(params.server_uuid_),
params.mesg_port_);

// Step 2: Register all RAFT parameters. At the end of this step, raft is ready to be created/join group
auto r_params = nuraft::raft_params()
Expand Down Expand Up @@ -161,7 +161,7 @@ void RaftReplService::raft_group_config_found(sisl::byte_view const& buf, void*

auto rdev = std::dynamic_pointer_cast< RaftReplDev >(*v);
auto listener = m_repl_app->create_repl_dev_listener(group_id);
listener->set_repl_dev(rdev.get());
listener->set_repl_dev(rdev);
rdev->attach_listener(std::move(listener));
rdev->use_config(std::move(group_config));
}
Expand Down Expand Up @@ -195,7 +195,7 @@ shared< nuraft_mesg::mesg_state_mgr > RaftReplService::create_state_mgr(int32_t

// Attach the listener to the raft
auto listener = m_repl_app->create_repl_dev_listener(group_id);
listener->set_repl_dev(rdev.get());
listener->set_repl_dev(rdev);
rdev->attach_listener(std::move(listener));

// Add the repl dev to the map
Expand Down

0 comments on commit 4da2de4

Please sign in to comment.