New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
debug: add a new API Compact. #2357
Changes from 3 commits
32792d4
c0ff5b1
b7760b0
b9320f3
92818bf
e03b11a
26b7c0c
06ecbfa
92536ca
12852d5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ use kvproto::{eraftpb, raft_serverpb}; | |
|
||
use raftstore::store::{keys, Engines, Iterable, Peekable}; | ||
use storage::{CF_DEFAULT, CF_LOCK, CF_RAFT, CF_WRITE}; | ||
use util::rocksdb::{compact_range, get_cf_handle}; | ||
|
||
pub type Result<T> = result::Result<T, Error>; | ||
|
||
|
@@ -151,6 +152,19 @@ impl Debugger { | |
Err(e) => Err(box_err!(e)), | ||
} | ||
} | ||
|
||
/// Compact the cf[start..end) in the db **by manual**. | ||
pub fn compact(&self, db: DB, cf: &str, start: &[u8], end: &[u8]) -> Result<()> { | ||
try!(validate_db_and_cf(db, cf)); | ||
let db = match db { | ||
DB::KV => &self.engines.kv_engine, | ||
DB::RAFT => &self.engines.raft_engine, | ||
_ => unreachable!(), | ||
}; | ||
let handle = box_try!(get_cf_handle(db, cf)); | ||
compact_range(db, handle, Some(start), Some(end), true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why true? /cc @zhangjinpeng1987 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. any update? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a mistake. I wil fix it. |
||
Ok(()) | ||
} | ||
} | ||
|
||
pub fn validate_db_and_cf(db: DB, cf: &str) -> Result<()> { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't panic in the debug API