8000 Revert "Send out empty heartbeats regardless of non-empty AppendEntri… · MohammedDeveloper/arangodb@af3f977 · GitHub
[go: up one dir, main page]

Skip to content

Commit af3f977

Browse files
committed
Revert "Send out empty heartbeats regardless of non-empty AppendEntriesRPC."
This reverts commit e974501.
1 parent 2852f80 commit af3f977

File tree

2 files changed

+14
-36
lines changed

2 files changed

+14
-36
lines changed

arangod/Agency/Agent.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -537,10 +537,7 @@ void Agent::sendAppendEntriesRPC() {
537537
// message if a timeout occurs.
538538

539539
_lastSent[followerId] = system_clock::now();
540-
// _constituent.notifyHeartbeatSent(followerId);
541-
// Do not notify constituent, because the AppendEntriesRPC here could
542-
// take a very long time, so this must not disturb the empty ones
543-
// being sent out.
540+
_constituent.notifyHeartbeatSent(followerId);
544541

545542
LOG_TOPIC(DEBUG, Logger::AGENCY)
546543
<< "Appending (" << (uint64_t) (TRI_microtime() * 1000000000.0) << ") "
@@ -594,13 +591,8 @@ void Agent::sendEmptyAppendEntriesRPC(std::string followerId) {
594591
3 * _config.minPing() * _config.timeoutMult(), true);
595592
_constituent.notifyHeartbeatSent(followerId);
596593

597-
double now = TRI_microtime();
598594
LOG_TOPIC(DEBUG, Logger::AGENCY)
599595
<< "Sending empty appendEntriesRPC to follower " << followerId;
600-
double diff = TRI_microtime() - now;
601-
if (diff > 0.01) {
602-
LOG_TOPIC(DEBUG, Logger::AGENCY) << "Logging of a line took more than 1/100 of a second, this is bad:" << diff;
603-
}
604596
}
605597

606598
void Agent::advanceCommitIndex() {

arangod/Agency/Constituent.cpp

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ void Constituent::candidate() {
271271

272272
if (_leaderID != NO_LEADER) {
273273
_leaderID = NO_LEADER;
274-
LOG_TOPIC(DEBUG, Logger::AGENCY) << "Set _leaderID to NO_LEADER in Constituent::candidate";
274+
LOG_TOPIC(DEBUG, Logger::AGENCY) << "Set _leaderID to NO_LEADER";
275275
}
276276

277277
if (_role != CANDIDATE) {
@@ -739,49 +739,35 @@ void Constituent::run() {
739739
} else if (role == CANDIDATE) {
740740
callElection(); // Run for office
741741
} else {
742-
double interval = 0.25 * _agent->config().minPing()
743-
* _agent->config().timeoutMult();
742+
// This is 1/4th of the minPing timeout (_cv.wait() below is in
743+
// microseconds):
744+
uint64_t timeout =
745+
static_cast<uint64_t>(250000.0 * _agent->config().minPing() *
746+
_agent->config().timeoutMult());
747+
{
748+
CONDITION_LOCKER(guardv, _cv);
749+
_cv.wait(timeout);
750+
}
744751

745752
double now = TRI_microtime();
746-
double nextWakeup = interval; // might be lowered below
747-
748753
std::string const myid = _agent->id();
749754
for (auto const& followerId : _agent->config().active()) {
750755
if (followerId != myid) {
751756
bool needed = false;
752757
{
753758
MUTEX_LOCKER(guard, _heartBeatMutex);
754759
auto it = _lastHeartbeatSent.find(followerId);
755-
if (it == _lastHeartbeatSent.end()) {
760+
if (it == _lastHeartbeatSent.end() ||
761+
now - it->second > _agent->config().minPing()
762+
* _agent->config().timeoutMult() / 4.0) {
756763
needed = true;
757-
} else {
758-
double diff = now - it->second;
759-
if (diff >= interval) {
760-
needed = true;
761-
} else {
762-
// diff < interval, so only needed again in interval-diff s
763-
double waitOnly = interval - diff;
764-
if (nextWakeup > waitOnly) {
765-
nextWakeup = waitOnly;
766-
}
767-
LOG_TOPIC(DEBUG, Logger::AGENCY)
768-
<< "No need for empty AppendEntriesRPC: " << diff;
769-
}
770764
}
771765
}
772766
if (needed) {
773767
_agent->sendEmptyAppendEntriesRPC(followerId);
774768
}
775769
}
776770
}
777-
778-
// This is the smallest time until any of the followers need a
779-
// new empty heartbeat:
780-
uint64_t timeout = static_cast<uint64_t>(1000000.0 * nextWakeup);
781-
{
782-
CONDITION_LOCKER(guardv, _cv);
783-
_cv.wait(timeout);
784-
}
785771
}
786772
}
787773
}

0 commit comments

Comments
 (0)
0