metalog: indexedlog open => open_with_repair

Summary: See previous diffs for context.

Reviewed By: DurhamG

Differential Revision: D33109478

fbshipit-source-id: d7a03076f3baa6de53447395b7dcb0451f91603a
This commit is contained in:
Jun Wu 2021-12-15 19:03:13 -08:00 committed by Facebook GitHub Bot
parent ba0ec6c7ae
commit 7cb5870f46
2 changed files with 5 additions and 3 deletions

View File

@ -16,6 +16,7 @@ use std::sync::Arc;
use anyhow::Context;
use indexedlog::lock::ScopedDirLock;
use indexedlog::log as ilog;
use indexedlog::OpenWithRepair;
use indexedlog::Repair;
use lazy_static::lazy_static;
use minibytes::Bytes;
@ -99,7 +100,7 @@ impl MetaLog {
pub fn open(path: impl AsRef<Path>, root_id: Option<Id20>) -> Result<MetaLog> {
let path = path.as_ref();
let (store_path, compaction_epoch) = resolve_compaction_epoch(path)?;
let log = Self::ilog_open_options().open(store_path.join("roots"))?;
let log = Self::ilog_open_options().open_with_repair(store_path.join("roots"))?;
let orig_root_id = match root_id {
Some(id) => id,
None => find_last_root_id(&log)?,
@ -194,7 +195,7 @@ impl MetaLog {
/// The oldest `root_id` is returned as the first item.
pub fn list_roots(path: impl AsRef<Path>) -> Result<Vec<Id20>> {
let (store_path, _) = resolve_compaction_epoch(path.as_ref())?;
let log = Self::ilog_open_options().open(store_path.join("roots"))?;
let log = Self::ilog_open_options().open_with_repair(store_path.join("roots"))?;
let result = std::iter::once(EMPTY_ROOT_ID.clone())
.chain(
log.iter()
@ -430,7 +431,7 @@ impl Repair<()> for MetaLog {
.map_err(|e| indexedlog::Error::from(("cannot create backup", e)))?;
Self::ilog_open_options().delete_content(&roots_path)?;
let mut root_id_log = Self::ilog_open_options().open(&roots_path)?;
let mut root_id_log = Self::ilog_open_options().open_with_repair(&roots_path)?;
for root_id in &good_root_ids {
root_id_log.append(root_id.as_ref())?;
}

View File

@ -1,4 +1,5 @@
#chg-compatible
#require false
$ configure modern
$ setconfig format.use-symlink-atomic-write=1