From c71d9e287ecafd7d5f6bf0d04f5e5df0cc2c87d9 Mon Sep 17 00:00:00 2001 From: Kaveh Vahedipour Date: Wed, 2 Nov 2016 15:44:54 +0100 Subject: [PATCH 1/3] do not override command line RAFT timings with estimates --- arangod/Agency/AgencyFeature.cpp | 10 +++++++-- arangod/Agency/AgencyFeature.h | 1 + arangod/Agency/AgentConfiguration.cpp | 14 +++++++++++-- arangod/Agency/AgentConfiguration.h | 6 +++++- arangod/Agency/Inception.cpp | 6 +++++- scripts/startStandAloneAgency.sh | 30 +++++++++------------------ 6 files changed, 41 insertions(+), 26 deletions(-) diff --git a/arangod/Agency/AgencyFeature.cpp b/arangod/Agency/AgencyFeature.cpp index 96189085b7..32c3c4b5e9 100644 --- a/arangod/Agency/AgencyFeature.cpp +++ b/arangod/Agency/AgencyFeature.cpp @@ -46,7 +46,9 @@ AgencyFeature::AgencyFeature(application_features::ApplicationServer* server) _waitForSync(true), _supervisionFrequency(5.0), _compactionStepSize(1000), - _supervisionGracePeriod(120.0) { + _supervisionGracePeriod(120.0), + _cmdLineTimings(false) +{ setOptional(true); requiresElevatedPrivileges(false); startsAfter("Database"); @@ -119,6 +121,10 @@ void AgencyFeature::validateOptions(std::shared_ptr options) { return; } + if (result.touched("agency.election-timout-min")) { + _cmdLineTimings = true; + } + ServerState::instance()->setRole(ServerState::ROLE_AGENT); // Agency size @@ -221,7 +227,7 @@ void AgencyFeature::start() { _agent.reset(new consensus::Agent(consensus::config_t( _size, _poolSize, _minElectionTimeout, _maxElectionTimeout, endpoint, _agencyEndpoints, _supervision, _waitForSync, _supervisionFrequency, - _compactionStepSize, _supervisionGracePeriod))); + _compactionStepSize, _supervisionGracePeriod, _cmdLineTimings))); LOG_TOPIC(DEBUG, Logger::AGENCY) << "Starting agency personality"; _agent->start(); diff --git a/arangod/Agency/AgencyFeature.h b/arangod/Agency/AgencyFeature.h index 055d1e280d..1187e84313 100644 --- a/arangod/Agency/AgencyFeature.h +++ b/arangod/Agency/AgencyFeature.h @@ -57,6 +57,7 @@ class AgencyFeature : virtual public application_features::ApplicationFeature { double _supervisionGracePeriod; std::string _agencyMyAddress; std::vector _agencyEndpoints; + bool _cmdLineTimings; public: consensus::Agent* agent() const { return _agent.get(); } diff --git a/arangod/Agency/AgentConfiguration.cpp b/arangod/Agency/AgentConfiguration.cpp index 8b6328eb3b..9258c3e5e6 100644 --- a/arangod/Agency/AgentConfiguration.cpp +++ b/arangod/Agency/AgentConfiguration.cpp @@ -39,12 +39,13 @@ config_t::config_t() _supervisionFrequency(5.0), _compactionStepSize(1000), _supervisionGracePeriod(120), + _cmdLineTimings(false), _lock() {} config_t::config_t(size_t as, size_t ps, double minp, double maxp, std::string const& e, std::vector const& g, - bool s, bool w, double f, uint64_t c, double p) + bool s, bool w, double f, uint64_t c, double p, bool t) : _agencySize(as), _poolSize(ps), _minPing(minp), @@ -56,6 +57,7 @@ config_t::config_t(size_t as, size_t ps, double minp, double maxp, _supervisionFrequency(f), _compactionStepSize(c), _supervisionGracePeriod(p), + _cmdLineTimings(t), _lock() {} config_t::config_t(config_t const& other) { *this = other; } @@ -74,7 +76,8 @@ config_t::config_t(config_t&& other) _waitForSync(std::move(other._waitForSync)), _supervisionFrequency(std::move(other._supervisionFrequency)), _compactionStepSize(std::move(other._compactionStepSize)), - _supervisionGracePeriod(std::move(other._supervisionGracePeriod)) {} + _supervisionGracePeriod(std::move(other._supervisionGracePeriod)), + _cmdLineTimings(std::move(other._cmdLineTimings)){} config_t& config_t::operator=(config_t const& other) { // must hold the lock of other to copy _pool, _minPing, _maxPing etc. @@ -94,6 +97,7 @@ config_t& config_t::operator=(config_t const& other) { _supervisionFrequency = other._supervisionFrequency; _compactionStepSize = other._compactionStepSize; _supervisionGracePeriod = other._supervisionGracePeriod; + _cmdLineTimings = other._cmdLineTimings; return *this; } @@ -112,9 +116,15 @@ config_t& config_t::operator=(config_t&& other) { _supervisionFrequency = std::move(other._supervisionFrequency); _compactionStepSize = std::move(other._compactionStepSize); _supervisionGracePeriod = std::move(other._supervisionGracePeriod); + _cmdLineTimings = std::move(other._cmdLineTimings); return *this; } +bool config_t::cmdLineTimings() const { + READ_LOCKER(readLocker, _lock); + return _cmdLineTimings; +} + double config_t::supervisionGracePeriod() const { READ_LOCKER(readLocker, _lock); return _supervisionGracePeriod; diff --git a/arangod/Agency/AgentConfiguration.h b/arangod/Agency/AgentConfiguration.h index 6a660bd237..13e871821f 100644 --- a/arangod/Agency/AgentConfiguration.h +++ b/arangod/Agency/AgentConfiguration.h @@ -68,6 +68,7 @@ struct config_t { double _supervisionFrequency; uint64_t _compactionStepSize; double _supervisionGracePeriod; + bool _cmdLineTimings; mutable arangodb::basics::ReadWriteLock _lock; // guard member variables @@ -77,7 +78,7 @@ struct config_t { /// @brief ctor config_t(size_t as, size_t ps, double minp, double maxp, std::string const& e, std::vector const& g, bool s, bool w, double f, - uint64_t c, double p); + uint64_t c, double p, bool t); /// @brief copy constructor config_t(config_t const&); @@ -171,6 +172,9 @@ struct config_t { /// @brief Reset RAFT timing void pingTimes(double, double); + /// @brief Supervision grace period + bool cmdLineTimings() const; + /// @brief Supervision grace period double supervisionGracePeriod() const; diff --git a/arangod/Agency/Inception.cpp b/arangod/Agency/Inception.cpp index 1d1e137b35..f9f79af065 100644 --- a/arangod/Agency/Inception.cpp +++ b/arangod/Agency/Inception.cpp @@ -490,7 +490,11 @@ void Inception::run() { FATAL_ERROR_EXIT(); } - estimateRAFTInterval(); + // 5. If command line RAFT timings have not been set explicitly + // Try good estimate of RAFT time limits + if (!config.cmdLineTimings()) { + estimateRAFTInterval(); + } _agent->ready(true); diff --git a/scripts/startStandAloneAgency.sh b/scripts/startStandAloneAgency.sh index e23239e4ad..1c65f43ee0 100755 --- a/scripts/startStandAloneAgency.sh +++ b/scripts/startStandAloneAgency.sh @@ -35,44 +35,34 @@ while [[ ${1} ]]; do case "${1}" in -a|--agency-size) NRAGENTS=${2} - shift - ;; + shift;; -p|--pool-size) POOLSZ=${2} - shift - ;; + shift;; -t|--transport) TRANSPORT=${2} - shift - ;; + shift;; -l|--log-level) LOG_LEVEL=${2} - shift - ;; + shift;; -w|--wait-for-sync) WAIT_FOR_SYNC=${2} - shift - ;; + shift;; -m|--use-microtime) USE_MICROTIME=${2} - shift - ;; + shift;; -g|--gossip-mode) GOSSIP_MODE=${2} - shift - ;; + shift;; -s|--start-delays) START_DELAYS=${2} - shift - ;; + shift;; -h|--help) - help - exit 1 + help; exit 1 ;; *) echo "Unknown parameter: ${1}" >&2 - help - exit 1 + help; exit 1 ;; esac From e9450e21c2d29d23d98fce176a4e025ba006545b Mon Sep 17 00:00:00 2001 From: Kaveh Vahedipour Date: Wed, 2 Nov 2016 15:57:49 +0100 Subject: [PATCH 2/3] don't override raft timeout cmd line inpute --- arangod/Agency/AgencyFeature.cpp | 2 +- js/client/modules/@arangodb/testing.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/arangod/Agency/AgencyFeature.cpp b/arangod/Agency/AgencyFeature.cpp index 32c3c4b5e9..1c37e33558 100644 --- a/arangod/Agency/AgencyFeature.cpp +++ b/arangod/Agency/AgencyFeature.cpp @@ -121,7 +121,7 @@ void AgencyFeature::validateOptions(std::shared_ptr options) { return; } - if (result.touched("agency.election-timout-min")) { + if (result.touched("agency.election-timeout-min")) { _cmdLineTimings = true; } diff --git a/js/client/modules/@arangodb/testing.js b/js/client/modules/@arangodb/testing.js index b60885103f..aea6a24166 100644 --- a/js/client/modules/@arangodb/testing.js +++ b/js/client/modules/@arangodb/testing.js @@ -1476,6 +1476,8 @@ function startInstanceAgency (instanceInfo, protocol, options, instanceArgs['agency.pool-size'] = String(N); instanceArgs['agency.wait-for-sync'] = String(wfs); instanceArgs['agency.supervision'] = String(S); + instanceArgs['agency.election-timeout-min'] = String(2); + instanceArgs['agency.election-timeout-max'] = String(10); instanceArgs['database.directory'] = dataDir + String(i); const port = findFreePort(options.maxPort); instanceArgs['server.endpoint'] = protocol + '://127.0.0.1:' + port; From d82079a59c45a3b05d1c78982204cdd107d8a5d8 Mon Sep 17 00:00:00 2001 From: Kaveh Vahedipour Date: Wed, 2 Nov 2016 16:02:37 +0100 Subject: [PATCH 3/3] don't override raft timeout cmd line inpute --- js/client/modules/@arangodb/testing.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/js/client/modules/@arangodb/testing.js b/js/client/modules/@arangodb/testing.js index aea6a24166..b60885103f 100644 --- a/js/client/modules/@arangodb/testing.js +++ b/js/client/modules/@arangodb/testing.js @@ -1476,8 +1476,6 @@ function startInstanceAgency (instanceInfo, protocol, options, instanceArgs['agency.pool-size'] = String(N); instanceArgs['agency.wait-for-sync'] = String(wfs); instanceArgs['agency.supervision'] = String(S); - instanceArgs['agency.election-timeout-min'] = String(2); - instanceArgs['agency.election-timeout-max'] = String(10); instanceArgs['database.directory'] = dataDir + String(i); const port = findFreePort(options.maxPort); instanceArgs['server.endpoint'] = protocol + '://127.0.0.1:' + port;