apache / incubator-pegasus

Apache Pegasus - A horizontally scalable, strongly consistent and high-performance key-value store
https://pegasus.apache.org/
Apache License 2.0
1.97k stars 314 forks source link

fix(balance): Distinguish cluster balanced or collecting balance info interruptted #1951

Closed Samunroyu closed 6 months ago

Samunroyu commented 6 months ago

What problem does this PR solve?

After scaling out, Pegasus determines whether the shards are balanced by checking if the balance operation counts are equal to 0. However, since the meta server returns counts = 0 when it cannot collect all replicas information, this leads to the premature termination of balancing. Therefore, in such cases, the counts should be equal to -1

What is changed and how does it work?

A new bool variable introduce into class greedy_load_balancer to control balance operation count whether be -1.

class greedy_load_balancer{
private:
    bool _all_replca_infos_collected;
}