diff --git a/conanfile.py b/conanfile.py index 2a30e53e6..d6a50ad01 100644 --- a/conanfile.py +++ b/conanfile.py @@ -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") diff --git a/src/include/homestore/replication/repl_dev.h b/src/include/homestore/replication/repl_dev.h index 28b494f0f..a1eee044f 100644 --- a/src/include/homestore/replication/repl_dev.h +++ b/src/include/homestore/replication/repl_dev.h @@ -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. /// @@ -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 { diff --git a/src/lib/homestore.cpp b/src/lib/homestore.cpp index b05387ee5..427fd6ddb 100644 --- a/src/lib/homestore.cpp +++ b/src/lib/homestore.cpp @@ -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 { @@ -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(); diff --git a/src/lib/replication/service/generic_repl_svc.cpp b/src/lib/replication/service/generic_repl_svc.cpp index 451c355dc..240c82623 100644 --- a/src/lib/replication/service/generic_repl_svc.cpp +++ b/src/lib/replication/service/generic_repl_svc.cpp @@ -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)); { @@ -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)); { diff --git a/src/lib/replication/service/raft_repl_service.cpp b/src/lib/replication/service/raft_repl_service.cpp index b0cfbca75..3a8e06e67 100644 --- a/src/lib/replication/service/raft_repl_service.cpp +++ b/src/lib/replication/service/raft_repl_service.cpp @@ -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() @@ -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)); } @@ -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