From 5a865b687c35b9ccdc1a4197bc1cef347fd45d36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Max=20Neunh=C3=B6ffer?= Date: Wed, 5 Sep 2018 21:14:07 +0200 Subject: [PATCH] Wait 2s after switching server mode before answering. (#6393) This is needed because the change is propagated via the agency and the heartbeat, which only happens once per second. --- arangod/Cluster/ServerState.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arangod/Cluster/ServerState.cpp b/arangod/Cluster/ServerState.cpp index 02bf76b241..6ca1f93813 100644 --- a/arangod/Cluster/ServerState.cpp +++ b/arangod/Cluster/ServerState.cpp @@ -794,6 +794,10 @@ Result ServerState::propagateClusterReadOnly(bool mode) { if (!r.successful()) { return Result(TRI_ERROR_CLUSTER_AGENCY_COMMUNICATION_FAILED, r.errorMessage()); } + // This is propagated to all servers via the heartbeat, which happens + // once per second. So to ensure that every server has taken note of + // the change, we delay here for 2 seconds. + std::this_thread::sleep_for(std::chrono::seconds(2)); } setReadOnly(mode); return Result();