Skip to content
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

feat: Remove ckb db-repair subcommand #3927

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions ckb-bin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ ckb-memory-tracker = { path = "../util/memory-tracker", version = "= 0.110.0-pre
ckb-chain-iter = { path = "../util/chain-iter", version = "= 0.110.0-pre" }
ckb-verification-traits = { path = "../verification/traits", version = "= 0.110.0-pre" }
ckb-async-runtime = { path = "../util/runtime", version = "= 0.110.0-pre" }
ckb-db = { path = "../db", version = "= 0.110.0-pre" }
ckb-launcher = { path = "../util/launcher", version = "= 0.110.0-pre" }
base64 = "0.21.0"
tempfile.workspace = true
Expand All @@ -50,5 +49,5 @@ deadlock_detection = ["ckb-util/deadlock_detection"]
profiling = ["ckb-memory-tracker/profiling"]
with_sentry = ["sentry", "ckb-launcher/with_sentry", "ckb-network/with_sentry", "ckb-app-config/with_sentry", "ckb-logger-service/with_sentry"]
with_dns_seeding = ["ckb-network/with_dns_seeding"]
portable = ["ckb-db/portable", "ckb-launcher/portable"]
march-native = ["ckb-db/march-native", "ckb-launcher/march-native"]
portable = ["ckb-launcher/portable"]
march-native = ["ckb-launcher/march-native"]
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}.");
Copy link
Collaborator

@chenyukang chenyukang Apr 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we remove db-repair,
any other follow-up actions should be shown here to guide users to resolve it.

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