revisionstore: add repair method on indexedlog-based stores

Summary: This just calls into the indexedlog repair API.

Reviewed By: xavierd

Differential Revision: D17755608

fbshipit-source-id: ff6c99cadfc900f8ab8c49fe887161492e08c692
This commit is contained in:
Jun Wu 2019-10-04 20:33:58 -07:00 committed by Facebook Github Bot
parent 0da18952b4
commit 3e99b568eb
2 changed files with 42 additions and 18 deletions

View File

@ -158,15 +158,8 @@ impl IndexedLogDataStore {
/// `IndexedLogDataStore` is being recreated, losing all data that was previously stored in
/// it.
pub fn new(path: impl AsRef<Path>) -> Fallible<Self> {
let open_options = OpenOptions::new()
.max_log_count(4)
.max_bytes_per_log(2500 * 1000 * 1000)
.create(true)
.index("node", |_| {
vec![IndexOutput::Reference(0..Node::len() as u64)]
});
let log = match open_options.clone().open(&path) {
let open_options = Self::default_open_options();
let log = match open_options.open(&path) {
Ok(log) => log,
Err(err) => {
// XXX: This removes or renames path, which can break various
@ -180,6 +173,25 @@ impl IndexedLogDataStore {
inner: Arc::new(RwLock::new(IndexedLogDataStoreInner { log })),
})
}
/// Attempt to repair data at the given path.
/// Return human-readable repair logs.
pub fn repair(path: impl AsRef<Path>) -> Fallible<String> {
let path = path.as_ref();
let open_options = Self::default_open_options();
Ok(open_options.repair(path)?)
}
/// Default configuration: 4 x 2.5GB.
fn default_open_options() -> OpenOptions {
OpenOptions::new()
.max_log_count(4)
.max_bytes_per_log(2500 * 1000 * 1000)
.create(true)
.index("node", |_| {
vec![IndexOutput::Reference(0..Node::len() as u64)]
})
}
}
impl MutableDeltaStore for IndexedLogDataStore {

View File

@ -190,15 +190,8 @@ impl IndexedLogHistoryStore {
/// `IndexedLogHistoryStore` is being recreated, losing all data that was previously stored in
/// it.
pub fn new(path: impl AsRef<Path>) -> Fallible<Self> {
let open_options = OpenOptions::new()
.max_log_count(4)
.max_bytes_per_log(500 * 1000 * 1000)
.create(true)
.index("node_and_path", |_| {
vec![IndexOutput::Reference(0..(Node::len() * 2) as u64)]
});
let log = match open_options.clone().open(&path) {
let open_options = Self::default_open_options();
let log = match open_options.open(&path) {
Ok(log) => log,
Err(err) => {
// XXX: This removes or renames path, which can break various
@ -212,6 +205,25 @@ impl IndexedLogHistoryStore {
inner: Arc::new(RwLock::new(IndexedLogHistoryStoreInner { log })),
})
}
/// Attempt to repair data at the given path.
/// Return human-readable repair logs.
pub fn repair(path: impl AsRef<Path>) -> Fallible<String> {
let path = path.as_ref();
let open_options = Self::default_open_options();
Ok(open_options.repair(path)?)
}
/// Default configuration: 4 x 0.5GB.
fn default_open_options() -> OpenOptions {
OpenOptions::new()
.max_log_count(4)
.max_bytes_per_log(500 * 1000 * 1000)
.create(true)
.index("node_and_path", |_| {
vec![IndexOutput::Reference(0..(Node::len() * 2) as u64)]
})
}
}
impl LocalStore for IndexedLogHistoryStore {