Skip to content

Commit 0770a2f

Browse files
lichuangmergify[bot]Xuanwo
authored
fix: when saved endpoints is empty, use endpoint config every try_config_endpoints_interval (#10848)
* fix: when saved endpoints is empty, use endpoint config every try_config_endpoints_interval * fix: when saved endpoints is empty, use endpoint config every try_config_endpoints_interval * fix: when saved endpoints is empty, use endpoint config every try_config_endpoints_interval * refactor: refactor by review comment * refactor: add unhealth_endpoint_evict_time config * fix: remove unused config * fix: fix test fail --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Xuanwo <[email protected]>
1 parent e8ff4a5 commit 0770a2f

File tree

18 files changed

+91
-11
lines changed

18 files changed

+91
-11
lines changed

docs/doc/10-deploy/07-query/10-query-config.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ You can find [sample configuration files](https://github.com/datafuselabs/databe
7272
* This setting only takes effect when Databend-query works with remote meta service(`endpoints` is not empty). You don't need to configure it for standalone Databend.
7373
* Default: 60
7474

75+
### unhealth_endpoint_evict_time
76+
77+
* Internal(in seconds) time that not querying an unhealth meta node endpoint.
78+
* Default: 120
79+
7580
## 3. Query config
7681

7782
### admin_api_address

docs/doc/13-sql-reference/20-system-tables/system-configs.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ mysql> SELECT * FROM system.configs;
6666
| meta | auto_sync_interval | 0 | |
6767
| meta | rpc_tls_meta_server_root_ca_cert | | |
6868
| meta | rpc_tls_meta_service_domain_name | localhost | |
69+
| meta | unhealth_endpoint_evict_time | 120 | |
6970
| cache | enable_table_meta_cache | true | |
7071
| cache | table_meta_snapshot_count | 256 | |
7172
| cache | table_meta_segment_count | 10240 | |

src/binaries/metabench/main.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use std::fmt::Debug;
1818
use std::fmt::Display;
1919
use std::sync::Arc;
20+
use std::time::Duration;
2021
use std::time::Instant;
2122

2223
use clap::Parser;
@@ -82,8 +83,15 @@ async fn main() {
8283
let prefix = config.prefix;
8384

8485
let handle = tokio::spawn(async move {
85-
let client =
86-
MetaGrpcClient::try_create(vec![addr.to_string()], "root", "xxx", None, None, None);
86+
let client = MetaGrpcClient::try_create(
87+
vec![addr.to_string()],
88+
"root",
89+
"xxx",
90+
None,
91+
None,
92+
Duration::from_secs(10),
93+
None,
94+
);
8795

8896
let client = match client {
8997
Ok(client) => client,

src/binaries/metactl/grpc.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,22 @@
1414

1515
use std::fs::File;
1616
use std::io::Write;
17+
use std::time::Duration;
1718

1819
use common_meta_client::MetaGrpcClient;
1920
use common_meta_types::protobuf::Empty;
2021
use tokio_stream::StreamExt;
2122

2223
pub async fn export_meta(addr: &str, save: String) -> anyhow::Result<()> {
23-
let client =
24-
MetaGrpcClient::try_create(vec![addr.to_string()], "root", "xxx", None, None, None)?;
24+
let client = MetaGrpcClient::try_create(
25+
vec![addr.to_string()],
26+
"root",
27+
"xxx",
28+
None,
29+
None,
30+
Duration::from_secs(10),
31+
None,
32+
)?;
2533

2634
let mut grpc_client = client.make_client().await?;
2735

src/binaries/metactl/main.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ use grpc::export_meta;
1919

2020
mod snapshot;
2121

22+
use std::time::Duration;
23+
2224
use clap::Parser;
2325
use common_base::base::tokio;
2426
use common_meta_client::MetaGrpcClient;
@@ -263,8 +265,15 @@ async fn bench_client_num_conn(conf: &Config) -> anyhow::Result<()> {
263265

264266
loop {
265267
i += 1;
266-
let client =
267-
MetaGrpcClient::try_create(vec![addr.to_string()], "root", "xxx", None, None, None)?;
268+
let client = MetaGrpcClient::try_create(
269+
vec![addr.to_string()],
270+
"root",
271+
"xxx",
272+
None,
273+
None,
274+
Duration::from_secs(10),
275+
None,
276+
)?;
268277

269278
let res = client.get_kv("foo").await;
270279
println!("{}-th: get_kv(foo): {:?}", i, res);

src/common/grpc/src/client_conf.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ pub struct RpcClientConf {
3838
/// AutoSyncInterval is the interval to update endpoints with its latest members.
3939
/// None disables auto-sync.
4040
pub auto_sync_interval: Option<Duration>,
41+
pub unhealth_endpoint_evict_time: Duration,
4142
}
4243

4344
impl RpcClientConf {

src/meta/client/src/grpc_client.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ impl MetaGrpcClient {
300300
&conf.password,
301301
conf.timeout,
302302
conf.auto_sync_interval,
303+
conf.unhealth_endpoint_evict_time,
303304
conf.tls_conf.clone(),
304305
)
305306
}
@@ -311,6 +312,7 @@ impl MetaGrpcClient {
311312
password: &str,
312313
timeout: Option<Duration>,
313314
auto_sync_interval: Option<Duration>,
315+
unhealth_endpoint_evict_time: Duration,
314316
conf: Option<RpcClientTlsConfig>,
315317
) -> Result<Arc<ClientHandle>, MetaClientError> {
316318
Self::endpoints_non_empty(&endpoints)?;
@@ -339,7 +341,7 @@ impl MetaGrpcClient {
339341
conn_pool: Pool::new(mgr, Duration::from_millis(50)),
340342
endpoints: RwLock::new(endpoints),
341343
current_endpoint: Arc::new(Mutex::new(None)),
342-
unhealthy_endpoints: Mutex::new(TtlHashMap::new(Duration::from_secs(120))),
344+
unhealthy_endpoints: Mutex::new(TtlHashMap::new(unhealth_endpoint_evict_time)),
343345
auto_sync_interval,
344346
username: username.to_string(),
345347
password: password.to_string(),

src/meta/client/tests/it/grpc_client.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,16 @@ async fn test_grpc_client_action_timeout() {
3636
// server's handshake impl will sleep 2secs.
3737
let timeout = Duration::from_secs(3);
3838

39-
let client =
40-
MetaGrpcClient::try_create(vec![srv_addr], "", "", Some(timeout), None, None).unwrap();
39+
let client = MetaGrpcClient::try_create(
40+
vec![srv_addr],
41+
"",
42+
"",
43+
Some(timeout),
44+
None,
45+
Duration::from_secs(10),
46+
None,
47+
)
48+
.unwrap();
4149

4250
let res = client
4351
.get_database(GetDatabaseReq::new("tenant1", "xx"))

src/meta/service/tests/it/grpc/metasrv_grpc_api.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ async fn test_restart() -> anyhow::Result<()> {
4949
"xxx",
5050
None,
5151
Some(Duration::from_secs(10)),
52+
Duration::from_secs(10),
5253
None,
5354
)?;
5455

@@ -116,6 +117,7 @@ async fn test_restart() -> anyhow::Result<()> {
116117
"xxx",
117118
None,
118119
Some(Duration::from_secs(10)),
120+
Duration::from_secs(10),
119121
None,
120122
)?;
121123

@@ -211,6 +213,7 @@ async fn test_join() -> anyhow::Result<()> {
211213
"xxx",
212214
None,
213215
Some(Duration::from_secs(10)),
216+
Duration::from_secs(10),
214217
None,
215218
)?;
216219
let client1 = MetaGrpcClient::try_create(
@@ -219,6 +222,7 @@ async fn test_join() -> anyhow::Result<()> {
219222
"xxx",
220223
None,
221224
Some(Duration::from_secs(10)),
225+
Duration::from_secs(10),
222226
None,
223227
)?;
224228

@@ -308,6 +312,7 @@ async fn test_auto_sync_addr() -> anyhow::Result<()> {
308312
"xxx",
309313
None,
310314
Some(Duration::from_secs(5)),
315+
Duration::from_secs(10),
311316
None,
312317
)?;
313318

src/meta/service/tests/it/grpc/metasrv_grpc_export.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ async fn test_export() -> anyhow::Result<()> {
4141
"xxx",
4242
None,
4343
Some(Duration::from_secs(10)),
44+
Duration::from_secs(10),
4445
None,
4546
)?;
4647

0 commit comments

Comments
 (0)