Skip to content

Commit

Permalink
feat: remove repair
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangsoledad committed Apr 8, 2023
1 parent 2f17fe6 commit dbeda66
Show file tree
Hide file tree
Showing 8 changed files with 5 additions and 69 deletions.
8 changes: 1 addition & 7 deletions ckb-bin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ pub fn run_app(version: Version) -> Result<(), ExitCode> {
cli::CMD_STATS => subcommand::stats(setup.stats(matches)?, handle),
cli::CMD_RESET_DATA => subcommand::reset_data(setup.reset_data(matches)?),
cli::CMD_MIGRATE => subcommand::migrate(setup.migrate(matches)?),
cli::CMD_DB_REPAIR => subcommand::db_repair(setup.db_repair(matches)?),
_ => unreachable!(),
};

Expand All @@ -86,11 +85,6 @@ type Silent = bool;
fn is_silent_logging(cmd: &str) -> Silent {
matches!(
cmd,
cli::CMD_EXPORT
| cli::CMD_IMPORT
| cli::CMD_STATS
| cli::CMD_MIGRATE
| cli::CMD_DB_REPAIR
| cli::CMD_RESET_DATA
cli::CMD_EXPORT | cli::CMD_IMPORT | cli::CMD_STATS | cli::CMD_MIGRATE | cli::CMD_RESET_DATA
)
}
11 changes: 0 additions & 11 deletions ckb-bin/src/subcommand/db_repair.rs

This file was deleted.

2 changes: 0 additions & 2 deletions ckb-bin/src/subcommand/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
mod db_repair;
mod export;
mod import;
mod init;
Expand All @@ -11,7 +10,6 @@ mod reset_data;
mod run;
mod stats;

pub use self::db_repair::db_repair;
pub use self::export::export;
pub use self::import::import;
pub use self::init::init;
Expand Down
19 changes: 1 addition & 18 deletions db/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,6 @@ impl RocksDB {
})
}

/// Repairer does best effort recovery to recover as much data as possible
/// after a disaster without compromising consistency.
/// It does not guarantee bringing the database to a time consistent state.
/// Note: Currently there is a limitation that un-flushed column families will be lost after repair.
/// This would happen even if the DB is in healthy state.
pub fn repair<P: AsRef<Path>>(path: P) -> Result<()> {
let repair_opts = Options::default();
OptimisticTransactionDB::repair(repair_opts, path)
.map_err(|err| internal_error(format!("failed to repair database: {err}")))
}

/// Open a database with the given configuration and columns count.
pub fn open(config: &DBConfig, columns: u32) -> Self {
Self::open_with_check(config, columns).unwrap_or_else(|err| panic!("{err}"))
Expand Down Expand Up @@ -127,13 +116,7 @@ impl RocksDB {
{
Ok(None)
} else if err_str.starts_with("Corruption:") {
info!(
"DB corrupted: {err_str}.\n\
Try ckb db-repair command to repair DB.\n\
Note: Currently there is a limitation that un-flushed column families will be lost after repair.\
This would happen even if the DB is in healthy state.\n\
See https://github.com/facebook/rocksdb/wiki/RocksDB-Repairer for detail",
);
info!("DB corrupted: {err_str}.");
Err(internal_error(err_str))
} else {
Err(internal_error(format!(
Expand Down
12 changes: 2 additions & 10 deletions db/src/read_only_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,10 @@ impl ReadOnlyDB {
|err| {
let err_str = err.as_ref();
// notice: err msg difference
if err_str.starts_with("IO error: No such file or directory")
{
if err_str.starts_with("IO error: No such file or directory") {
Ok(None)
} else if err_str.starts_with("Corruption:") {
info!(
"DB corrupted: {}.\n\
Try ckb db-repair command to repair DB.\n\
Note: Currently there is a limitation that un-flushed column families will be lost after repair.\
This would happen even if the DB is in healthy state.\n\
See https://github.com/facebook/rocksdb/wiki/RocksDB-Repairer for detail",
err_str
);
info!("DB corrupted: {err_str}.");
Err(internal_error("DB corrupted"))
} else {
Err(internal_error(format!(
Expand Down
6 changes: 0 additions & 6 deletions util/app-config/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,6 @@ pub struct MigrateArgs {
pub force: bool,
}

/// Parsed command line arguments for `ckb db-repair`.
pub struct RepairArgs {
/// Parsed `ckb.toml`.
pub config: Box<CKBAppConfig>,
}

impl CustomizeSpec {
/// No specified parameters for chain spec.
pub fn is_unset(&self) -> bool {
Expand Down
7 changes: 0 additions & 7 deletions util/app-config/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ pub const CMD_GEN_SECRET: &str = "gen";
pub const CMD_FROM_SECRET: &str = "from-secret";
/// Subcommand `migrate`.
pub const CMD_MIGRATE: &str = "migrate";
/// Subcommand `db-repair`.
pub const CMD_DB_REPAIR: &str = "db-repair";

/// Command line argument `--config-dir`.
pub const ARG_CONFIG_DIR: &str = "config-dir";
Expand Down Expand Up @@ -145,7 +143,6 @@ pub fn basic_app() -> Command {
.subcommand(reset_data())
.subcommand(peer_id())
.subcommand(migrate())
.subcommand(db_repair())
}

/// Parse the command line arguments by supplying the version information.
Expand Down Expand Up @@ -374,10 +371,6 @@ fn migrate() -> Command {
)
}

fn db_repair() -> Command {
Command::new(CMD_DB_REPAIR).about("Try repair ckb database")
}

fn list_hashes() -> Command {
Command::new(CMD_LIST_HASHES)
.about("Lists well known hashes")
Expand Down
9 changes: 1 addition & 8 deletions util/app-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub use app_config::{
AppConfig, CKBAppConfig, ChainConfig, LogConfig, MetricsConfig, MinerAppConfig,
};
pub use args::{
ExportArgs, ImportArgs, InitArgs, MigrateArgs, MinerArgs, PeerIDArgs, RepairArgs, ReplayArgs,
ExportArgs, ImportArgs, InitArgs, MigrateArgs, MinerArgs, PeerIDArgs, ReplayArgs,
ResetDataArgs, RunArgs, StatsArgs,
};
pub use configs::*;
Expand Down Expand Up @@ -116,13 +116,6 @@ impl Setup {
})
}

/// `db-repair` subcommand
pub fn db_repair(self, _matches: &ArgMatches) -> Result<RepairArgs, ExitCode> {
let config = self.config.into_ckb()?;

Ok(RepairArgs { config })
}

/// Executes `ckb miner`.
pub fn miner(self, matches: &ArgMatches) -> Result<MinerArgs, ExitCode> {
let spec = self.chain_spec()?;
Expand Down

0 comments on commit dbeda66

Please sign in to comment.