From 43bd8c9c75f64a832adc792762382d9d79b0deab Mon Sep 17 00:00:00 2001 From: August Date: Tue, 4 Apr 2023 12:14:10 +0800 Subject: [PATCH] fix: use original lru crate in meta client and simulation (#8956) --- Cargo.lock | 15 ++++++++++++--- src/rpc_client/Cargo.toml | 2 +- src/rpc_client/src/meta_client.rs | 5 +++-- src/tests/simulation/Cargo.toml | 2 +- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ee0c49c7db59..3afcbbcc3459 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3532,6 +3532,15 @@ dependencies = [ "hashbrown 0.12.3", ] +[[package]] +name = "lru" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03f1160296536f10c833a82dca22267d5486734230d47bf00bf435885814ba1e" +dependencies = [ + "hashbrown 0.13.2", +] + [[package]] name = "lz4" version = "1.24.0" @@ -6465,7 +6474,7 @@ dependencies = [ "either", "futures", "itertools", - "lru", + "lru 0.10.0", "madsim-tokio", "madsim-tonic", "moka", @@ -6508,7 +6517,7 @@ dependencies = [ "futures", "glob", "itertools", - "lru", + "lru 0.10.0", "madsim", "madsim-aws-sdk-s3", "madsim-etcd-client", @@ -6713,7 +6722,7 @@ dependencies = [ "iter-chunks", "itertools", "local_stats_alloc", - "lru", + "lru 0.7.6", "madsim-tokio", "madsim-tonic", "maplit", diff --git a/src/rpc_client/Cargo.toml b/src/rpc_client/Cargo.toml index a62baeecb673..4ba44d7b8854 100644 --- a/src/rpc_client/Cargo.toml +++ b/src/rpc_client/Cargo.toml @@ -19,7 +19,7 @@ async-trait = "0.1" either = "1.8.1" futures = { version = "0.3", default-features = false, features = ["alloc"] } itertools = "0.10.5" -lru = { git = "https://github.com/risingwavelabs/lru-rs.git", branch = "evict_by_timestamp" } +lru = "0.10.0" rand = "0.8" risingwave_common = { path = "../common" } risingwave_hummock_sdk = { path = "../storage/hummock_sdk" } diff --git a/src/rpc_client/src/meta_client.rs b/src/rpc_client/src/meta_client.rs index 230853ab06d8..911fe6006992 100644 --- a/src/rpc_client/src/meta_client.rs +++ b/src/rpc_client/src/meta_client.rs @@ -15,6 +15,7 @@ use std::collections::HashMap; use std::fmt; use std::fmt::{Debug, Formatter}; +use std::num::NonZeroUsize; use std::sync::Arc; use std::time::Duration; @@ -1142,7 +1143,7 @@ impl ElectionMemberManagement { None => { let endpoint = GrpcMetaClient::addr_to_endpoint(addr.clone())?; let channel = GrpcMetaClient::connect_to_endpoint(endpoint).await?; - let new_client: MetaMemberServiceClient = + let new_client: MetaMemberClient = MetaMemberServiceClient::new(channel); *client = Some(new_client.clone()); @@ -1299,7 +1300,7 @@ impl GrpcMetaClient { let members = match &strategy { MetaAddressStrategy::LoadBalance(_) => Either::Left(meta_member_client), MetaAddressStrategy::List(addrs) => { - let mut members = LruCache::new(20); + let mut members = LruCache::new(NonZeroUsize::new(20).unwrap()); for addr in addrs { members.put(addr.clone(), None); } diff --git a/src/tests/simulation/Cargo.toml b/src/tests/simulation/Cargo.toml index 6fd353dfb56c..801a76801c48 100644 --- a/src/tests/simulation/Cargo.toml +++ b/src/tests/simulation/Cargo.toml @@ -20,7 +20,7 @@ etcd-client = { version = "0.2.17", package = "madsim-etcd-client" } futures = { version = "0.3", default-features = false, features = ["alloc"] } glob = "0.3" itertools = "0.10" -lru = { git = "https://github.com/risingwavelabs/lru-rs.git", branch = "evict_by_timestamp" } +lru = "0.10.0" madsim = "0.2.17" paste = "1" pin-project = "1.0"