mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-04 20:32:56 +00:00
refactor: arrange lease kvs randomly in lease_based selector (#2028)
* refactor: arrange lease kvs randomly in lease_based selector * fix: cr
This commit is contained in:
@@ -13,6 +13,8 @@
|
||||
// limitations under the License.
|
||||
|
||||
use api::v1::meta::Peer;
|
||||
use rand::seq::SliceRandom;
|
||||
use rand::thread_rng;
|
||||
|
||||
use crate::error::Result;
|
||||
use crate::lease;
|
||||
@@ -34,9 +36,7 @@ impl Selector for LeaseBasedSelector {
|
||||
.into_iter()
|
||||
.collect();
|
||||
|
||||
// TODO(jiachun): At the moment we are just pushing the latest to the forefront,
|
||||
// and it is better to use load-based strategies in the future.
|
||||
lease_kvs.sort_by(|a, b| b.1.timestamp_millis.cmp(&a.1.timestamp_millis));
|
||||
lease_kvs.shuffle(&mut thread_rng());
|
||||
|
||||
let peers = lease_kvs
|
||||
.into_iter()
|
||||
|
||||
Reference in New Issue
Block a user