Skip to content

Commit 6ce5c72

Browse files
authored
Merge pull request #249 from hongyunyan/hongyunyan-merge-tikv-master
Merge TiKV(bce01cf) into Proxy
2 parents 18639c5 + a4e4358 commit 6ce5c72

260 files changed

Lines changed: 14448 additions & 5467 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 22 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "tikv"
3-
version = "6.5.0-alpha"
3+
version = "6.6.0-alpha"
44
authors = ["The TiKV Authors"]
55
description = "A distributed transactional key-value database powered by Rust and Raft"
66
license = "Apache-2.0"
@@ -137,6 +137,7 @@ protobuf = { version = "2.8", features = ["bytes"] }
137137
raft = { version = "0.7.0", default-features = false, features = ["protobuf-codec"] }
138138
raft_log_engine = { workspace = true }
139139
raftstore = { workspace = true, features = ["engine_rocks"] }
140+
raftstore-v2 = { workspace = true }
140141
rand = "0.7.3"
141142
regex = "1.3"
142143
resource_metering = { workspace = true }
@@ -154,7 +155,7 @@ smallvec = "1.4"
154155
sst_importer = { workspace = true }
155156
strum = { version = "0.20", features = ["derive"] }
156157
sync_wrapper = "0.1.1"
157-
sysinfo = "0.16"
158+
sysinfo = "0.26"
158159
tempfile = "3.0"
159160
thiserror = "1.0"
160161
tidb_query_aggr = { workspace = true }
@@ -339,7 +340,7 @@ pd_client = { path = "components/pd_client" }
339340
profiler = { path = "components/profiler" }
340341
raft_log_engine = { path = "components/raft_log_engine" }
341342
raftstore = { path = "components/raftstore", default-features = false }
342-
raftstore_v2 = { path = "components/raftstore-v2", default-features = false }
343+
raftstore-v2 = { path = "components/raftstore-v2", default-features = false }
343344
resolved_ts = { path = "components/resolved_ts" }
344345
resource_metering = { path = "components/resource_metering" }
345346
security = { path = "components/security" }
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ The following are the versions that we support for security updates
1818

1919
| Version | Supported |
2020
| ------- | ------------------ |
21+
| 6.x | :white_check_mark: |
22+
| 5.x | :white_check_mark: |
2123
| 4.x | :white_check_mark: |
2224
| 3.x | :white_check_mark: |
2325
| 2.x | :white_check_mark: |
@@ -94,4 +96,4 @@ IvCICV7zG1cyuM/Z2Y7/TJ+upvahP46nM3s3G15b8FYuTSmRN1Kp9+mBt2BHqOy1
9496
ulx+VF4Lf9n3ydf593Nha9bMJ/rnSp01
9597
=XbYK
9698
-----END PGP PUBLIC KEY BLOCK-----
97-
```
99+
```

cmd/tikv-ctl/src/executor.rs

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
// Copyright 2021 TiKV Project Authors. Licensed under Apache-2.0.
22

33
use std::{
4-
borrow::ToOwned, cmp::Ordering, path::PathBuf, pin::Pin, str, string::ToString, sync::Arc,
5-
time::Duration, u64,
4+
borrow::ToOwned, cmp::Ordering, pin::Pin, str, string::ToString, sync::Arc, time::Duration, u64,
65
};
76

87
use encryption_export::data_key_manager_from_config;
@@ -28,7 +27,10 @@ use security::SecurityManager;
2827
use serde_json::json;
2928
use tikv::{
3029
config::{ConfigController, TikvConfig},
31-
server::debug::{BottommostLevelCompaction, Debugger, RegionInfo},
30+
server::{
31+
debug::{BottommostLevelCompaction, Debugger, RegionInfo},
32+
KvEngineFactoryBuilder,
33+
},
3234
};
3335
use tikv_util::escape;
3436

@@ -45,7 +47,6 @@ type MvccInfoStream = Pin<Box<dyn Stream<Item = Result<(Vec<u8>, MvccInfo), Stri
4547
pub fn new_debug_executor(
4648
cfg: &TikvConfig,
4749
data_dir: Option<&str>,
48-
skip_paranoid_checks: bool,
4950
host: Option<&str>,
5051
mgr: Arc<SecurityManager>,
5152
) -> Box<dyn DebugExecutor> {
@@ -55,47 +56,37 @@ pub fn new_debug_executor(
5556

5657
// TODO: perhaps we should allow user skip specifying data path.
5758
let data_dir = data_dir.unwrap();
58-
let kv_path = cfg.infer_kv_engine_path(Some(data_dir)).unwrap();
5959

6060
let key_manager = data_key_manager_from_config(&cfg.security.encryption, &cfg.storage.data_dir)
6161
.unwrap()
6262
.map(Arc::new);
6363

6464
let cache = cfg.storage.block_cache.build_shared_cache();
65-
let shared_block_cache = cache.is_some();
6665
let env = cfg
6766
.build_shared_rocks_env(key_manager.clone(), None /* io_rate_limiter */)
6867
.unwrap();
6968

70-
let mut kv_db_opts = cfg.rocksdb.build_opt();
71-
kv_db_opts.set_env(env.clone());
72-
kv_db_opts.set_paranoid_checks(!skip_paranoid_checks);
73-
let kv_cfs_opts = cfg
74-
.rocksdb
75-
.build_cf_opts(&cache, None, cfg.storage.api_version());
76-
let kv_path = PathBuf::from(kv_path).canonicalize().unwrap();
77-
let kv_path = kv_path.to_str().unwrap();
78-
let mut kv_db = match new_engine_opt(kv_path, kv_db_opts, kv_cfs_opts) {
69+
let factory = KvEngineFactoryBuilder::new(env.clone(), cfg, cache)
70+
.lite(true)
71+
.build();
72+
let kv_db = match factory.create_shared_db(data_dir) {
7973
Ok(db) => db,
8074
Err(e) => handle_engine_error(e),
8175
};
82-
kv_db.set_shared_block_cache(shared_block_cache);
8376

8477
let cfg_controller = ConfigController::default();
8578
if !cfg.raft_engine.enable {
86-
let mut raft_db_opts = cfg.raftdb.build_opt();
87-
raft_db_opts.set_env(env);
88-
let raft_db_cf_opts = cfg.raftdb.build_cf_opts(&cache);
79+
let raft_db_opts = cfg.raftdb.build_opt(env, None);
80+
let raft_db_cf_opts = cfg.raftdb.build_cf_opts(factory.block_cache());
8981
let raft_path = cfg.infer_raft_db_path(Some(data_dir)).unwrap();
9082
if !db_exist(&raft_path) {
9183
error!("raft db not exists: {}", raft_path);
9284
tikv_util::logger::exit_process_gracefully(-1);
9385
}
94-
let mut raft_db = match new_engine_opt(&raft_path, raft_db_opts, raft_db_cf_opts) {
86+
let raft_db = match new_engine_opt(&raft_path, raft_db_opts, raft_db_cf_opts) {
9587
Ok(db) => db,
9688
Err(e) => handle_engine_error(e),
9789
};
98-
raft_db.set_shared_block_cache(shared_block_cache);
9990
let debugger = Debugger::new(Engines::new(kv_db, raft_db), cfg_controller);
10091
Box::new(debugger) as Box<dyn DebugExecutor>
10192
} else {
@@ -383,7 +374,7 @@ pub trait DebugExecutor {
383374
to_config: &TikvConfig,
384375
mgr: Arc<SecurityManager>,
385376
) {
386-
let rhs_debug_executor = new_debug_executor(to_config, to_data_dir, false, to_host, mgr);
377+
let rhs_debug_executor = new_debug_executor(to_config, to_data_dir, to_host, mgr);
387378

388379
let r1 = self.get_region_info(region);
389380
let r2 = rhs_debug_executor.get_region_info(region);

cmd/tikv-ctl/src/main.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ fn main() {
5959

6060
// Initialize configuration and security manager.
6161
let cfg_path = opt.config.as_ref();
62-
let cfg = cfg_path.map_or_else(
62+
let mut cfg = cfg_path.map_or_else(
6363
|| {
6464
let mut cfg = TikvConfig::default();
6565
cfg.log.level = tikv_util::logger::get_level_by_string("warn")
@@ -249,9 +249,8 @@ fn main() {
249249
.exit();
250250
}
251251

252-
let skip_paranoid_checks = opt.skip_paranoid_checks;
253-
let debug_executor =
254-
new_debug_executor(&cfg, data_dir, skip_paranoid_checks, host, Arc::clone(&mgr));
252+
cfg.rocksdb.paranoid_checks = Some(!opt.skip_paranoid_checks);
253+
let debug_executor = new_debug_executor(&cfg, data_dir, host, Arc::clone(&mgr));
255254

256255
match cmd {
257256
Cmd::Print { cf, key } => {
@@ -643,7 +642,7 @@ fn compact_whole_cluster(
643642
.name(format!("compact-{}", addr))
644643
.spawn_wrapper(move || {
645644
tikv_alloc::add_thread_memory_accessor();
646-
let debug_executor = new_debug_executor(&cfg, None, false, Some(&addr), mgr);
645+
let debug_executor = new_debug_executor(&cfg, None, Some(&addr), mgr);
647646
for cf in cfs {
648647
debug_executor.compact(
649648
Some(&addr),
@@ -682,20 +681,20 @@ fn read_fail_file(path: &str) -> Vec<(String, String)> {
682681
list
683682
}
684683

685-
fn run_ldb_command(args: Vec<String>, cfg: &TikvConfig) {
684+
fn build_rocks_opts(cfg: &TikvConfig) -> engine_rocks::RocksDbOptions {
686685
let key_manager = data_key_manager_from_config(&cfg.security.encryption, &cfg.storage.data_dir)
687686
.unwrap()
688687
.map(Arc::new);
689688
let env = get_env(key_manager, None /* io_rate_limiter */).unwrap();
690-
let mut opts = cfg.rocksdb.build_opt();
691-
opts.set_env(env);
689+
cfg.rocksdb.build_opt(&cfg.rocksdb.build_resources(env))
690+
}
692691

693-
engine_rocks::raw::run_ldb_tool(&args, &opts);
692+
fn run_ldb_command(args: Vec<String>, cfg: &TikvConfig) {
693+
engine_rocks::raw::run_ldb_tool(&args, &build_rocks_opts(cfg));
694694
}
695695

696696
fn run_sst_dump_command(args: Vec<String>, cfg: &TikvConfig) {
697-
let opts = cfg.rocksdb.build_opt();
698-
engine_rocks::raw::run_sst_dump_tool(&args, &opts);
697+
engine_rocks::raw::run_sst_dump_tool(&args, &build_rocks_opts(cfg));
699698
}
700699

701700
fn print_bad_ssts(data_dir: &str, manifest: Option<&str>, pd_client: RpcClient, cfg: &TikvConfig) {
@@ -714,7 +713,7 @@ fn print_bad_ssts(data_dir: &str, manifest: Option<&str>, pd_client: RpcClient,
714713

715714
let stderr = BufferRedirect::stderr().unwrap();
716715
let stdout = BufferRedirect::stdout().unwrap();
717-
let opts = cfg.rocksdb.build_opt();
716+
let opts = build_rocks_opts(cfg);
718717

719718
match run_and_wait_child_process(|| engine_rocks::raw::run_sst_dump_tool(&args, &opts)) {
720719
Ok(code) => {

0 commit comments

Comments
 (0)