Skip to content

Commit

Permalink
config: expose lock compact interval (tikv#1346)
Browse files Browse the repository at this point in the history
  • Loading branch information
BusyJay authored Nov 24, 2016
1 parent e94477a commit 589df54
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 13 deletions.
7 changes: 7 additions & 0 deletions etc/config-template.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ region-split-check-diff = "8MB"
# we will consider this peer to be down and report it to pd.
max-peer-down-duration = "5m"

# Interval to check whether start compaction for a region.
# region-compact-check-interval-secs = 300
# When delete keys of a region exceeds the size, a compaction will be started.
# region-compact-delete-keys-count = 200000
# Interval to check whether start lock compaction for a region.
# lock-cf-compact-interval-secs = 600

[pd]
# pd endpoints
endpoints = ""
Expand Down
13 changes: 9 additions & 4 deletions src/bin/tikv-server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,15 +404,20 @@ fn build_cfg(matches: &Matches, config: &toml::Value, cluster_id: u64, addr: &st
"raftstore.region-split-check-diff",
Some(8 * 1024 * 1024)) as u64;

cfg.raft_store.region_compact_check_tick_interval =
cfg.raft_store.region_compact_check_interval_secs =
get_toml_int(config,
"raftstore.region-compact-check-tick-interval",
Some(300_000)) as u64;
"raftstore.region-compact-check-interval-secs",
Some(300)) as u64;

cfg.raft_store.region_compact_delete_keys_count =
get_toml_int(config,
"raftstore.region-compact-delete-keys-count",
Some(200_000)) as u64;
Some(1_000_000)) as u64;

cfg.raft_store.lock_cf_compact_interval_secs =
get_toml_int(config,
"raftstore.lock-cf-compact-interval-secs",
Some(300_000)) as u64;

let max_peer_down_millis =
get_toml_int(config, "raftstore.max-peer-down-duration", Some(300_000)) as u64;
Expand Down
8 changes: 4 additions & 4 deletions src/raftstore/store/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const SPLIT_REGION_CHECK_TICK_INTERVAL: u64 = 10000;
const REGION_SPLIT_SIZE: u64 = 64 * 1024 * 1024;
const REGION_MAX_SIZE: u64 = 80 * 1024 * 1024;
const REGION_CHECK_DIFF: u64 = 8 * 1024 * 1024;
const REGION_COMPACT_CHECK_TICK_INTERVAL: u64 = 300_000;
const REGION_COMPACT_CHECK_TICK_INTERVAL: u64 = 300;
const REGION_COMPACT_DELETE_KEYS_COUNT: u64 = 1_000_000;
const PD_HEARTBEAT_TICK_INTERVAL_MS: u64 = 5000;
const PD_STORE_HEARTBEAT_TICK_INTERVAL_MS: u64 = 10000;
Expand Down Expand Up @@ -75,8 +75,8 @@ pub struct Config {
/// When size change of region exceed the diff since last check, it
/// will be checked again whether it should be split.
pub region_check_size_diff: u64,
/// Interval (ms) to check whether start compaction for a region.
pub region_compact_check_tick_interval: u64,
/// Interval to check whether start compaction for a region.
pub region_compact_check_interval_secs: u64,
/// When delete keys of a region exceeds the size, a compaction will
/// be started.
pub region_compact_delete_keys_count: u64,
Expand Down Expand Up @@ -117,7 +117,7 @@ impl Default for Config {
region_max_size: REGION_MAX_SIZE,
region_split_size: REGION_SPLIT_SIZE,
region_check_size_diff: REGION_CHECK_DIFF,
region_compact_check_tick_interval: REGION_COMPACT_CHECK_TICK_INTERVAL,
region_compact_check_interval_secs: REGION_COMPACT_CHECK_TICK_INTERVAL,
region_compact_delete_keys_count: REGION_COMPACT_DELETE_KEYS_COUNT,
pd_heartbeat_tick_interval: PD_HEARTBEAT_TICK_INTERVAL_MS,
pd_store_heartbeat_tick_interval: PD_STORE_HEARTBEAT_TICK_INTERVAL_MS,
Expand Down
12 changes: 8 additions & 4 deletions src/raftstore/store/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1222,7 +1222,7 @@ impl<T: Transport, C: PdClient> Store<T, C> {
fn register_compact_check_tick(&self, event_loop: &mut EventLoop<Self>) {
if let Err(e) = register_timer(event_loop,
Tick::CompactCheck,
self.cfg.region_compact_check_tick_interval) {
self.cfg.region_compact_check_interval_secs * 1000) {
error!("{} register compact check tick err: {:?}", self.tag, e);
};
}
Expand Down Expand Up @@ -1572,11 +1572,15 @@ impl<T: Transport, C: PdClient> Store<T, C> {
fn register_timer<T: Transport, C: PdClient>(event_loop: &mut EventLoop<Store<T, C>>,
tick: Tick,
delay: u64)
-> Result<mio::Timeout> {
-> Result<()> {
// TODO: now mio TimerError doesn't implement Error trait,
// so we can't use `try!` directly.
event_loop.timeout(tick, Duration::from_millis(delay))
.map_err(|e| box_err!("register timer err: {:?}", e))
if delay == 0 {
// 0 delay means turn off the timer.
return Ok(());
}
box_try!(event_loop.timeout(tick, Duration::from_millis(delay)));
Ok(())
}

fn new_compact_log_request(region_id: u64,
Expand Down
2 changes: 1 addition & 1 deletion tests/raftstore/test_compact_after_delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use super::node::new_node_cluster;
use super::server::new_server_cluster;

fn test_compact_after_delete<T: Simulator>(cluster: &mut Cluster<T>) {
cluster.cfg.raft_store.region_compact_check_tick_interval = 500;
cluster.cfg.raft_store.region_compact_check_interval_secs = 500;
cluster.cfg.raft_store.region_compact_delete_keys_count = 5;
cluster.run();

Expand Down

0 comments on commit 589df54

Please sign in to comment.