config: override rocksdb config when flow control enabled
@@ -2722,10 +2722,51 @@ impl TiKvConfig {
self.raftdb.defaultcf.soft_pending_compaction_bytes_limit = ReadableSize(0);
self.raftdb.defaultcf.hard_pending_compaction_bytes_limit = ReadableSize(0);
+ // disable kvdb write stall, and override related configs
self.rocksdb.defaultcf.disable_write_stall = true;
+ self.rocksdb.defaultcf.level0_slowdown_writes_trigger =
+ self.storage.flow_control.l0_files_threshold as i32;
+ self.rocksdb.defaultcf.soft_pending_compaction_bytes_limit = self
+ .storage
+ .flow_control
+ .soft_pending_compaction_bytes_limit;
+ self.rocksdb.defaultcf.hard_pending_compaction_bytes_limit = self
+ .storage
+ .flow_control
+ .hard_pending_compaction_bytes_limit;
self.rocksdb.writecf.disable_write_stall = true;
+ self.rocksdb.writecf.level0_slowdown_writes_trigger =
+ self.storage.flow_control.l0_files_threshold as i32;
+ self.rocksdb.writecf.soft_pending_compaction_bytes_limit = self
+ .storage
+ .flow_control
+ .soft_pending_compaction_bytes_limit;
+ self.rocksdb.writecf.hard_pending_compaction_bytes_limit = self
+ .storage
+ .flow_control
+ .hard_pending_compaction_bytes_limit;
self.rocksdb.lockcf.disable_write_stall = true;
+ self.rocksdb.lockcf.level0_slowdown_writes_trigger =
+ self.storage.flow_control.l0_files_threshold as i32;
+ self.rocksdb.lockcf.soft_pending_compaction_bytes_limit = self
+ .storage
+ .flow_control
+ .soft_pending_compaction_bytes_limit;
+ self.rocksdb.lockcf.hard_pending_compaction_bytes_limit = self
+ .storage
+ .flow_control
+ .hard_pending_compaction_bytes_limit;
self.rocksdb.raftcf.disable_write_stall = true;
+ self.rocksdb.raftcf.level0_slowdown_writes_trigger =
+ self.storage.flow_control.l0_files_threshold as i32;
+ self.rocksdb.raftcf.soft_pending_compaction_bytes_limit = self
+ .storage
+ .flow_control
+ .soft_pending_compaction_bytes_limit;
+ self.rocksdb.raftcf.hard_pending_compaction_bytes_limit = self
+ .storage
+ .flow_control
+ .hard_pending_compaction_bytes_limit;
}
if let Some(memory_usage_limit) = self.memory_usage_limit.0 {
@@ -3829,11 +3870,25 @@ mod tests {
}
#[test]
- fn test_change_flow_control() {
+ fn test_flow_control() {
let (mut cfg, _dir) = TiKvConfig::with_tmp().unwrap();
+ cfg.storage.flow_control.l0_files_threshold = 50;
cfg.validate().unwrap();
let (db, cfg_controller, _, flow_controller) = new_engines(cfg);
+ assert_eq!(
+ db.get_options_cf(CF_DEFAULT)
+ .unwrap()
+ .get_level_zero_slowdown_writes_trigger(),
+ 50
+ );
+ assert_eq!(
+ db.get_options_cf(CF_DEFAULT)
+ .unwrap()
+ .get_level_zero_stop_writes_trigger(),
+ 50
+ );
+
assert_eq!(
db.get_options_cf(CF_DEFAULT)
.unwrap()
