From a8c5d1292a23eb992d29b905041f764bda5bfa5b Mon Sep 17 00:00:00 2001 From: Tao He Date: Tue, 20 Jul 2021 11:26:29 +0800 Subject: [PATCH] Use the same etcd prefix when launching vineyard from multiple engines. (#559) Signed-off-by: Tao He --- analytical_engine/core/launcher.cc | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/analytical_engine/core/launcher.cc b/analytical_engine/core/launcher.cc index 8515771e735a..caeef69e4d4c 100644 --- a/analytical_engine/core/launcher.cc +++ b/analytical_engine/core/launcher.cc @@ -32,17 +32,24 @@ void VineyardServer::Start() { return; } + // Use a unique timestamp as the etcd prefix to avoid contention between + // unrelated vineyardd processes. + uint64_t ts = 0; + if (comm_spec_.worker_id() == 0) { + ts = std::chrono::duration_cast( + std::chrono::system_clock::now().time_since_epoch()) + .count(); + grape::BcastSend(ts, comm_spec_.comm()); + } else { + grape::BcastRecv(ts, comm_spec_.comm(), 0); + } + if (comm_spec_.local_id() != 0) { // Only launch one vineyard instance at each machine. grape::BcastRecv(vineyard_socket_, comm_spec_.local_comm(), 0); return; } - // Use a unique timestamp as the etcd prefix to avoid contention between - // unrelated vineyardd processes. - auto ts = std::chrono::duration_cast( - std::chrono::system_clock::now().time_since_epoch()) - .count(); if (getenv("VINEYARD_IPC_SOCKET")) { vineyard_socket_ = vineyard::ExpandEnvironmentVariables("$VINEYARD_IPC_SOCKET");