1
0
Fork 0

The heartbeat thread updates the agency endpoint once per second but did not put the leader in front, instead it put them in lexico order. Thus in case the leader is not the first server, each server in the cluster forgot which server was the actual leader and asked the first named follower, just to be redirected immediately.

This commit is contained in:
lamai93 2019-11-13 13:56:51 +01:00
parent 4ebe84f512
commit b1f14c3a3c
1 changed files with 8 additions and 1 deletions

View File

@ -1306,8 +1306,15 @@ void HeartbeatThread::updateAgentPool(VPackSlice const& agentPool) {
agentPool.hasKey("size") && agentPool.get("size").getUInt() > 0) {
try {
std::vector<std::string> values;
// we have to make sure that the leader is on the front
auto leaderId = agentPool.get("id").stringRef();
auto pool = agentPool.get("pool");
values.emplace_back(pool.get(leaderId).copyString());
// now add all non leaders
for (auto pair : VPackObjectIterator(agentPool.get("pool"))) {
values.emplace_back(pair.value.copyString());
if (!pair.key.isEqualString(leaderId)) {
values.emplace_back(pair.value.copyString());
}
}
AgencyCommManager::MANAGER->updateEndpoints(values);
} catch (basics::Exception const& e) {