mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'devel' of https://github.com/arangodb/arangodb into devel
This commit is contained in:
commit
e2cea4e773
|
@ -312,7 +312,7 @@ void Agent::sendAppendEntriesRPC() {
|
||||||
|
|
||||||
for (auto const& followerId : _config.active()) {
|
for (auto const& followerId : _config.active()) {
|
||||||
|
|
||||||
if (followerId != myid) {
|
if (followerId != myid && leading()) {
|
||||||
|
|
||||||
term_t t(0);
|
term_t t(0);
|
||||||
|
|
||||||
|
@ -370,6 +370,11 @@ void Agent::sendAppendEntriesRPC() {
|
||||||
<< highest << " to follower " << followerId;
|
<< highest << " to follower " << followerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Really leading?
|
||||||
|
if (challengeLeadership()) {
|
||||||
|
_constituent.candidate();
|
||||||
|
}
|
||||||
|
|
||||||
// Send request
|
// Send request
|
||||||
auto headerFields =
|
auto headerFields =
|
||||||
std::make_unique<std::unordered_map<std::string, std::string>>();
|
std::make_unique<std::unordered_map<std::string, std::string>>();
|
||||||
|
@ -705,17 +710,12 @@ void Agent::run() {
|
||||||
// Leader working only
|
// Leader working only
|
||||||
if (leading()) {
|
if (leading()) {
|
||||||
|
|
||||||
// Really leading?
|
// Append entries to followers
|
||||||
if (challengeLeadership()) {
|
sendAppendEntriesRPC();
|
||||||
_constituent.candidate();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Don't panic
|
// Don't panic
|
||||||
_appendCV.wait(1000);
|
_appendCV.wait(1000);
|
||||||
|
|
||||||
// Append entries to followers
|
|
||||||
sendAppendEntriesRPC();
|
|
||||||
|
|
||||||
// Detect faulty agent and replace
|
// Detect faulty agent and replace
|
||||||
// if possible and only if not already activating
|
// if possible and only if not already activating
|
||||||
if (duration<double>(system_clock::now() - tp).count() > 10.0) {
|
if (duration<double>(system_clock::now() - tp).count() > 10.0) {
|
||||||
|
@ -862,6 +862,11 @@ void Agent::beginShutdown() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Agent::prepareLead() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/// Becoming leader
|
/// Becoming leader
|
||||||
bool Agent::lead() {
|
bool Agent::lead() {
|
||||||
// Key value stores
|
// Key value stores
|
||||||
|
|
|
@ -83,6 +83,9 @@ class Agent : public arangodb::Thread {
|
||||||
/// @brief Pick up leadership tasks
|
/// @brief Pick up leadership tasks
|
||||||
bool lead();
|
bool lead();
|
||||||
|
|
||||||
|
/// @brief Prepare leadership
|
||||||
|
bool prepareLead();
|
||||||
|
|
||||||
/// @brief Load persistent state
|
/// @brief Load persistent state
|
||||||
bool load();
|
bool load();
|
||||||
|
|
||||||
|
|
|
@ -210,8 +210,13 @@ void Constituent::lead(term_t term,
|
||||||
LOG_TOPIC(DEBUG, Logger::AGENCY) << ss.str();
|
LOG_TOPIC(DEBUG, Logger::AGENCY) << ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
// we need to rebuild spear_head and read_db;
|
// we need to rebuild spear_head and read_db
|
||||||
|
_agent->prepareLead();
|
||||||
|
|
||||||
|
|
||||||
|
// we need to start work as leader
|
||||||
_agent->lead();
|
_agent->lead();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Become candidate
|
/// Become candidate
|
||||||
|
@ -564,7 +569,7 @@ void Constituent::run() {
|
||||||
// in the beginning, pure random
|
// in the beginning, pure random
|
||||||
if (_lastHeartbeatSeen > 0.0) {
|
if (_lastHeartbeatSeen > 0.0) {
|
||||||
double now = TRI_microtime();
|
double now = TRI_microtime();
|
||||||
randWait -= static_cast<int64_t>(M * (now - _lastHeartbeatSeen));
|
randWait -= static_cast<int64_t>(M * (_lastHeartbeatSeen-now));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -447,7 +447,7 @@ bool Inception::estimateRAFTInterval() {
|
||||||
|
|
||||||
double precision = 1.0e-2;
|
double precision = 1.0e-2;
|
||||||
mn = precision *
|
mn = precision *
|
||||||
std::ceil((1. / precision)*(1. + precision * (maxmean + 3.*maxstdev)));
|
std::ceil((1. / precision)*(.35 + precision * (maxmean + 3.*maxstdev)));
|
||||||
if (config.waitForSync()) {
|
if (config.waitForSync()) {
|
||||||
mn *= 4.;
|
mn *= 4.;
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,14 +60,10 @@ Supervision::Supervision()
|
||||||
Supervision::~Supervision() { shutdown(); };
|
Supervision::~Supervision() { shutdown(); };
|
||||||
|
|
||||||
void Supervision::wakeUp() {
|
void Supervision::wakeUp() {
|
||||||
{
|
|
||||||
MUTEX_LOCKER(locker, _lock);
|
|
||||||
updateSnapshot();
|
updateSnapshot();
|
||||||
upgradeAgency();
|
upgradeAgency();
|
||||||
}
|
|
||||||
|
|
||||||
CONDITION_LOCKER(guard, _cv);
|
|
||||||
_cv.signal();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string const syncPrefix = "/Sync/ServerStates/";
|
static std::string const syncPrefix = "/Sync/ServerStates/";
|
||||||
|
@ -441,6 +437,12 @@ void Supervision::run() {
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!this->isStopping()) {
|
while (!this->isStopping()) {
|
||||||
|
|
||||||
|
// Get bunch of job IDs from agency for future jobs
|
||||||
|
if (_jobId == 0 || _jobId == _jobIdMax) {
|
||||||
|
getUniqueIds(); // cannot fail but only hang
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
MUTEX_LOCKER(locker, _lock);
|
MUTEX_LOCKER(locker, _lock);
|
||||||
|
|
||||||
|
@ -542,11 +544,6 @@ void Supervision::handleShutdown() {
|
||||||
|
|
||||||
// Guarded by caller
|
// Guarded by caller
|
||||||
bool Supervision::handleJobs() {
|
bool Supervision::handleJobs() {
|
||||||
// Get bunch of job IDs from agency for future jobs
|
|
||||||
if (_jobId == 0 || _jobId == _jobIdMax) {
|
|
||||||
getUniqueIds(); // cannot fail but only hang
|
|
||||||
}
|
|
||||||
|
|
||||||
// Do supervision
|
// Do supervision
|
||||||
|
|
||||||
shrinkCluster();
|
shrinkCluster();
|
||||||
|
@ -882,10 +879,9 @@ void Supervision::getUniqueIds() {
|
||||||
// is initialized by some other server...
|
// is initialized by some other server...
|
||||||
while (!this->isStopping()) {
|
while (!this->isStopping()) {
|
||||||
try {
|
try {
|
||||||
latestId = std::stoul(_agent->readDB()
|
MUTEX_LOCKER(locker, _lock);
|
||||||
.get(_agencyPrefix + "/Sync/LatestID")
|
latestId = std::stoul(
|
||||||
.slice()
|
_agent->readDB().get(_agencyPrefix + "/Sync/LatestID").slice().toJson());
|
||||||
.toJson());
|
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -163,7 +163,7 @@ mkdir -p agency
|
||||||
PIDS=""
|
PIDS=""
|
||||||
|
|
||||||
aaid=(`seq 0 $(( $POOLSZ - 1 ))`)
|
aaid=(`seq 0 $(( $POOLSZ - 1 ))`)
|
||||||
shuffle
|
#shuffle
|
||||||
|
|
||||||
count=1
|
count=1
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue