场景:
observer、ob-configserver部署成功,且使用obkv-table-client-java测试正常。obkv-table-client-rs的demo编译正常,运行报错。
报错信息:
frank@LAPTOP-4OF1323N:~/ob/obkv/obkv_cli$ cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.21s
Running `target/debug/obkv_cli`
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: MySqlError { ERROR 1193 (HY000): Unknown system variable 'socket' }', /home/frank/.cargo/registry/src/mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd/mysql-16.1.0/src/conn/mod.rs:1760:61
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
详细报错信息:
frank@LAPTOP-4OF1323N:~/ob/obkv/obkv_cli$ RUST_BACKTRACE=full cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.69s
Running `target/debug/obkv_cli`
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: MySqlError { ERROR 1193 (HY000): Unknown system variable 'socket' }', /home/frank/.cargo/registry/src/mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd/mysql-16.1.0/src/conn/mod.rs:1760:61
stack backtrace:
0: 0x560e07436cc0 - std::backtrace_rs::backtrace::libunwind::trace::h32eb3e08e874dd27
at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
1: 0x560e07436cc0 - std::backtrace_rs::backtrace::trace_unsynchronized::haa3f451d27bc11a5
at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x560e07436cc0 - std::sys_common::backtrace::_print_fmt::h5b94a01bb4289bb5
at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/sys_common/backtrace.rs:66:5
3: 0x560e07436cc0 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hb070b7fa7e3175df
at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/sys_common/backtrace.rs:45:22
4: 0x560e0745a42e - core::fmt::write::hd5207aebbb9a86e9
at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/core/src/fmt/mod.rs:1202:17
5: 0x560e07430b95 - std::io::Write::write_fmt::h3bd699bbd129ab8a
at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/io/mod.rs:1679:15
6: 0x560e074384f3 - std::sys_common::backtrace::_print::h7a21be552fdf58da
at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/sys_common/backtrace.rs:48:5
7: 0x560e074384f3 - std::sys_common::backtrace::print::ha85c41fe4dd80b13
at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/sys_common/backtrace.rs:35:9
8: 0x560e074384f3 - std::panicking::default_hook::{{closure}}::h04cca40023d0eeca
at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/panicking.rs:295:22
9: 0x560e074381df - std::panicking::default_hook::haa3ca8c310ed5402
at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/panicking.rs:314:9
10: 0x560e07438b9a - std::panicking::rust_panic_with_hook::h7b190ce1a948faac
at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/panicking.rs:698:17
11: 0x560e07438a97 - std::panicking::begin_panic_handler::{{closure}}::hbafbfdc3e1b97f68
at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/panicking.rs:588:13
12: 0x560e0743716c - std::sys_common::backtrace::__rust_end_short_backtrace::hda93e5fef243b4c0
at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/sys_common/backtrace.rs:138:18
13: 0x560e074387b2 - rust_begin_unwind
at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/panicking.rs:584:5
14: 0x560e069f72d3 - core::panicking::panic_fmt::h8d17ca1073d9a733
at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/core/src/panicking.rs:142:14
15: 0x560e069f7423 - core::result::unwrap_failed::hfaddf24b248137d3
at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/core/src/result.rs:1785:5
16: 0x560e070f868b - core::result::Result<T,E>::unwrap::hd6ca67c4717efe46
at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/core/src/result.rs:1107:23
17: 0x560e07107801 - mysql::conn::Conn::get_system_var::h266a2955a72cb6a1
at /home/frank/.cargo/registry/src/mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd/mysql-16.1.0/src/conn/mod.rs:1760:20
18: 0x560e070fd2ce - mysql::conn::Conn::can_improved::h9ce62211aa045e11
at /home/frank/.cargo/registry/src/mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd/mysql-16.1.0/src/conn/mod.rs:713:26
19: 0x560e070fd86f - mysql::conn::Conn::new::h204349fa80266ed3
at /home/frank/.cargo/registry/src/mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd/mysql-16.1.0/src/conn/mod.rs:734:37
20: 0x560e0711e8ce - mysql::conn::pool::InnerPool::new_conn::hcc71942bbf27d52a
at /home/frank/.cargo/registry/src/mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd/mysql-16.1.0/src/conn/pool.rs:43:15
21: 0x560e0711e761 - mysql::conn::pool::InnerPool::new::h2984a33ddecf7061
at /home/frank/.cargo/registry/src/mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd/mysql-16.1.0/src/conn/pool.rs:38:13
22: 0x560e06b0011a - mysql::conn::pool::Pool::new_manual::hc31bb0b50ebbccd0
at /home/frank/.cargo/registry/src/mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd/mysql-16.1.0/src/conn/pool.rs:200:20
23: 0x560e06acbd55 - obkv::location::ObTableLocation::get_or_create_mysql_pool::he665093014ad6c6c
at /home/frank/ob/obkv/obkv-table-client-rs/src/location/mod.rs:567:33
24: 0x560e06acde75 - obkv::location::ObTableLocation::get_table_entry_from_remote::hb099b29e8cb6f108
at /home/frank/ob/obkv/obkv-table-client-rs/src/location/mod.rs:816:20
25: 0x560e06acd338 - obkv::location::ObTableLocation::load_table_entry_randomly::hbbb127c1b5fe71a7
at /home/frank/ob/obkv/obkv-table-client-rs/src/location/mod.rs:664:9
26: 0x560e06a9d575 - obkv::client::table_client::ObTableClientInner::init_metadata::h97474ac57aadcd07
at /home/frank/ob/obkv/obkv-table-client-rs/src/client/table_client.rs:1273:13
27: 0x560e06a9b22d - obkv::client::table_client::ObTableClientInner::init::h26e654a285580413
at /home/frank/ob/obkv/obkv-table-client-rs/src/client/table_client.rs:1142:9
28: 0x560e06a9fd3b - obkv::client::table_client::ObTableClient::init::h84cd50a11ba30a5f
at /home/frank/ob/obkv/obkv-table-client-rs/src/client/table_client.rs:1489:9
29: 0x560e069fba1c - obkv_cli::build_client::ha0c2d099ef90f6d0
at /home/frank/ob/obkv/obkv_cli/src/main.rs:37:5
30: 0x560e069fbfd6 - obkv_cli::main::h8cc4d8f2d6733d3e
at /home/frank/ob/obkv/obkv_cli/src/main.rs:76:18
31: 0x560e069f809b - core::ops::function::FnOnce::call_once::h8587ff7b46b6bd57
at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/core/src/ops/function.rs:248:5
32: 0x560e069f795e - std::sys_common::backtrace::__rust_begin_short_backtrace::h7927763c39832bbb
at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/sys_common/backtrace.rs:122:18
33: 0x560e069f7731 - std::rt::lang_start::{{closure}}::h128c88e20d637041
at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/rt.rs:166:18
34: 0x560e0742d12f - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::hb69be6e0857c6cfb
at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/core/src/ops/function.rs:283:13
35: 0x560e0742d12f - std::panicking::try::do_call::h396dfc441ee9c786
at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/panicking.rs:492:40
36: 0x560e0742d12f - std::panicking::try::h6cdda972d28b3a4f
at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/panicking.rs:456:19
37: 0x560e0742d12f - std::panic::catch_unwind::h376039ec264e8ef9
at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/panic.rs:137:14
38: 0x560e0742d12f - std::rt::lang_start_internal::{{closure}}::hc94720ca3d4cb727
at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/rt.rs:148:48
39: 0x560e0742d12f - std::panicking::try::do_call::h2422fb95933fa2d5
at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/panicking.rs:492:40
40: 0x560e0742d12f - std::panicking::try::h488286b5ec8333ff
at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/panicking.rs:456:19
41: 0x560e0742d12f - std::panic::catch_unwind::h81636549836d2a25
at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/panic.rs:137:14
42: 0x560e0742d12f - std::rt::lang_start_internal::h6ba1bb743c1e9df9
at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/rt.rs:148:20
43: 0x560e069f770a - std::rt::lang_start::h572baf80932b36e1
at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/rt.rs:165:17
44: 0x560e069fc1d1 - main
45: 0x7fc944aced90 - <unknown>
46: 0x7fc944acee40 - __libc_start_main
47: 0x560e069f7605 - _start
48: 0x0 - <unknown>
测试代码:
// Copyright 2022 CeresDB Project Authors. Licensed under Apache-2.0.
extern crate obkv;
use std::{sync::Arc, thread, time};
use obkv::{serde_obkv::value::Value, Builder, ClientConfig, ObTableClient, RunningMode, Table};
// TODO: use test conf to control which environments to test.
const TEST_FULL_USER_NAME: &str = "frank@sys#obcluster";
const TEST_URL: &str = "http://172.18.108.43:8080/services?Action=ObRootServiceInfo&ObCluster=obcluster&database=test";
const TEST_PASSWORD: &str = "frank";
const TEST_SYS_USER_NAME: &str = "root@sys";
const TEST_SYS_PASSWORD: &str = "root";
fn build_client(mode: RunningMode) -> ObTableClient {
let mut config = ClientConfig::default();
config.min_idle_conns_per_server = 1;
config.max_conns_per_server = 1;
config.rpc_connect_timeout = std::time::Duration::from_secs(1);
config.metadata_mysql_conn_pool_max_size = 1;
config.metadata_mysql_conn_pool_min_size = 1;
let builder = Builder::new()
.full_user_name(TEST_FULL_USER_NAME)
.param_url(TEST_URL)
.running_mode(mode)
.password(TEST_PASSWORD)
.sys_user_name(TEST_SYS_USER_NAME)
.sys_password(TEST_SYS_PASSWORD);
let client = builder.build();
assert!(client.is_ok());
let client = client.unwrap();
client.init().expect("Fail to create obkv client.");
client
}
const TABLE_NAME: &str = "series_key_to_id_0";
// read and write the table:
// create table series_key_to_id_0 (
// series_key VARBINARY(8096) NOT NULL,
// series_id BIGINT NOT NULL,
// PRIMARY KEY(series_key),
// KEY index_id(series_id)
// );
fn concurrent_insert(client: Arc<ObTableClient>) {
let mut thds = Vec::with_capacity(20);
for i in 0..50 {
let client = client.clone();
let thd = thread::spawn(move || {
for j in i * 100..(i * 100 + 50) {
let series_key = format!("series_key_test_padding_padding_{}", j);
let series_id = j * j;
client
.insert(
TABLE_NAME,
vec![Value::from(series_key.clone())],
vec!["series_id".to_owned()],
vec![Value::from(series_id as i64)],
)
.expect(&format!("fail to insert row:{} {}", series_key, series_id));
}
});
thds.push(thd);
}
for (i, thd) in thds.into_iter().enumerate() {
thd.join().expect(&format!("thread#{} fail to join", i));
}
}
fn main() {
let client = build_client(RunningMode::Normal);
client
.truncate_table(TABLE_NAME)
.expect("fail to truncate the table");
let start = time::Instant::now();
concurrent_insert(Arc::new(client));
let elapsed = time::Instant::now() - start;
println!("Benches::concurrent_insert cost time:{:?}", elapsed);
}
curl测试ob-configserver正常:
frank@LAPTOP-4OF1323N:~/ob/obkv/obkv_cli$ curl "http://172.18.108.43:8080/services?Action=ObRootServiceInfo&ObCluster=obcluster&database=test" | jq
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 337 100 337 0 0 29355 0 --:--:-- --:--:-- --:--:-- 30636
{
"Code": 200,
"Message": "successful",
"Success": true,
"Data": {
"ObClusterId": 1,
"ObRegionId": 1,
"ObCluster": "obcluster",
"ObRegion": "obcluster",
"ReadonlyRsList": [],
"RsList": [
{
"address": "127.0.0.1:2882",
"role": "LEADER",
"sql_port": 2881
}
],
"Type": "PRIMARY",
"timestamp": 1668058564676408
},
"Trace": "0a55540c19c43d88",
"Server": "172.18.108.43",
"Cost": 6
}