mirror of https://gitee.com/bigwinds/arangodb
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:
parent
4ebe84f512
commit
b1f14c3a3c
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue