From 55df580c786229ad1448b567b9ae8729b55c01c2 Mon Sep 17 00:00:00 2001 From: Kaveh Vahedipour Date: Wed, 7 Sep 2016 09:49:47 +0200 Subject: [PATCH 1/2] bug fix in shutdown timer for tests --- js/client/modules/@arangodb/testing.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/js/client/modules/@arangodb/testing.js b/js/client/modules/@arangodb/testing.js index d0cdb1d694..f0d6d082d2 100644 --- a/js/client/modules/@arangodb/testing.js +++ b/js/client/modules/@arangodb/testing.js @@ -1226,6 +1226,8 @@ function shutdownInstance (instanceInfo, options) { let count = 0; let bar = '['; + var shutdownTime = require('internal').time(); + let toShutdown = instanceInfo.arangods.slice(); while (toShutdown.length > 0) { // Once all other servers are shut down, we take care of the agents, @@ -1241,13 +1243,8 @@ function shutdownInstance (instanceInfo, options) { arangod.exitStatus = statusExternal(arangod.pid, false); if (arangod.exitStatus.status === 'RUNNING') { - ++count; - if (count % 10 === 0) { - bar = bar + '#'; - } - - if (count > timeout) { + if ((require('internal').time() - shutdownTime) > timeout) { print('forcefully terminating ' + yaml.safeDump(arangod.pid) + ' after ' + timeout + 's grace period; marking crashy.'); serverCrashed = true; From f5cb4e7e1e429c9090f05316769d11e00ca87d08 Mon Sep 17 00:00:00 2001 From: Kaveh Vahedipour Date: Wed, 7 Sep 2016 09:50:36 +0200 Subject: [PATCH 2/2] replaced sleep_for by wait in inception phase --- arangod/Agency/Constituent.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/arangod/Agency/Constituent.cpp b/arangod/Agency/Constituent.cpp index 9f2ac12604..4b76964e2c 100644 --- a/arangod/Agency/Constituent.cpp +++ b/arangod/Agency/Constituent.cpp @@ -414,7 +414,8 @@ void Constituent::run() { std::vector act = _agent->config().active(); while (!this->isStopping() && ((size_t)(find(act.begin(), act.end(), _id) - act.begin()) >= size())) { - std::this_thread::sleep_for(std::chrono::milliseconds(5000)); + CONDITION_LOCKER(guardv, _cv); + _cv.wait(5000000); } if (size() == 1) { @@ -428,33 +429,33 @@ void Constituent::run() { MUTEX_LOCKER(guard, _castLock); _cast = false; // New round set not cast vote } - + int32_t left = static_cast(1000000.0 * _agent->config().minPing()), - right = static_cast(1000000.0 * - _agent->config().maxPing()); + right = static_cast(1000000.0 * + _agent->config().maxPing()); long rand_wait = - static_cast(RandomGenerator::interval(left, right)); - + static_cast(RandomGenerator::interval(left, right)); + { CONDITION_LOCKER(guardv, _cv); _cv.wait(rand_wait); } - + { MUTEX_LOCKER(guard, _castLock); cast = _cast; } - + if (!cast) { candidate(); // Next round, we are running } - + } else if (_role == CANDIDATE) { callElection(); // Run for office } else { int32_t left = - static_cast(100000.0 * _agent->config().minPing()); + static_cast(100000.0 * _agent->config().minPing()); long rand_wait = static_cast(left); { CONDITION_LOCKER(guardv, _cv);