diff --git a/src/storage/concurrent_id_mapper_master.cpp b/src/storage/concurrent_id_mapper_master.cpp index b19c977d0..a182ec485 100644 --- a/src/storage/concurrent_id_mapper_master.cpp +++ b/src/storage/concurrent_id_mapper_master.cpp @@ -32,7 +32,10 @@ ID_VALUE_RPC_CALLS(Property) template <typename TId> MasterConcurrentIdMapper<TId>::MasterConcurrentIdMapper( communication::messaging::System &system) - : rpc_server_(system, kConcurrentIdMapperRpc) { + // We have to make sure our rpc server name is unique with regards to type. + // Otherwise we will try to reuse the same rpc server name for different + // types (Label/EdgeType/Property) + : rpc_server_(system, impl::RpcServerNameFromType<TId>()) { RegisterRpc(*this, rpc_server_); } diff --git a/src/storage/concurrent_id_mapper_rpc_messages.hpp b/src/storage/concurrent_id_mapper_rpc_messages.hpp index 815e61f3e..d7c92103e 100644 --- a/src/storage/concurrent_id_mapper_rpc_messages.hpp +++ b/src/storage/concurrent_id_mapper_rpc_messages.hpp @@ -14,6 +14,16 @@ namespace storage { const std::string kConcurrentIdMapperRpc = "ConcurrentIdMapper"; const auto kConcurrentIdMapperRpcTimeout = 300ms; +namespace impl { + +/// Returns rpc server name by template type +template <typename TType> +std::string RpcServerNameFromType() { + return kConcurrentIdMapperRpc + "_" + typeid(TType).name(); +} + +}; // namespace impl + #define ID_VALUE_RPC(type) \ RPC_SINGLE_MEMBER_MESSAGE(type##IdReq, std::string); \ RPC_SINGLE_MEMBER_MESSAGE(type##IdRes, storage::type); \ diff --git a/src/storage/concurrent_id_mapper_worker.cpp b/src/storage/concurrent_id_mapper_worker.cpp index 2fbeaf8af..f49fa7d99 100644 --- a/src/storage/concurrent_id_mapper_worker.cpp +++ b/src/storage/concurrent_id_mapper_worker.cpp @@ -35,7 +35,8 @@ template <typename TId> WorkerConcurrentIdMapper<TId>::WorkerConcurrentIdMapper( communication::messaging::System &system, const io::network::Endpoint &master_endpoint) - : rpc_client_(system, master_endpoint, kConcurrentIdMapperRpc) {} + : rpc_client_(system, master_endpoint, impl::RpcServerNameFromType<TId>()) { +} template <typename TId> TId WorkerConcurrentIdMapper<TId>::value_to_id(const std::string &value) { diff --git a/tests/unit/database_master.cpp b/tests/unit/database_master.cpp new file mode 100644 index 000000000..24cb62664 --- /dev/null +++ b/tests/unit/database_master.cpp @@ -0,0 +1,11 @@ +#include "gtest/gtest.h" + +#include "config.hpp" +#include "database/graph_db.hpp" + +TEST(DatabaseMaster, Instantiate) { + database::Config config; + config.master_endpoint = io::network::Endpoint("127.0.0.1", 0); + config.worker_id = 0; + database::Master master(config); +}