improve database repair/shutdown log messages
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
a95ded167f
commit
a74613be96
1 changed files with 19 additions and 5 deletions
|
@ -1,10 +1,11 @@
|
||||||
use std::{
|
use std::{
|
||||||
collections::{BTreeSet, HashMap},
|
collections::{BTreeSet, HashMap},
|
||||||
fmt::Write,
|
fmt::Write,
|
||||||
|
path::PathBuf,
|
||||||
sync::{atomic::AtomicU32, Arc, Mutex, RwLock},
|
sync::{atomic::AtomicU32, Arc, Mutex, RwLock},
|
||||||
};
|
};
|
||||||
|
|
||||||
use conduit::{debug, error, info, utils::time::rfc2822_from_seconds, warn, Result, Server};
|
use conduit::{debug, error, info, utils::time::rfc2822_from_seconds, warn, Err, Result, Server};
|
||||||
use rocksdb::{
|
use rocksdb::{
|
||||||
backup::{BackupEngine, BackupEngineOptions},
|
backup::{BackupEngine, BackupEngineOptions},
|
||||||
perf::get_memory_usage_stats,
|
perf::get_memory_usage_stats,
|
||||||
|
@ -50,10 +51,7 @@ impl Engine {
|
||||||
|
|
||||||
let load_time = std::time::Instant::now();
|
let load_time = std::time::Instant::now();
|
||||||
if config.rocksdb_repair {
|
if config.rocksdb_repair {
|
||||||
warn!("Starting database repair. This may take a long time...");
|
repair(&db_opts, &config.database_path)?;
|
||||||
if let Err(e) = Db::repair(&db_opts, &config.database_path) {
|
|
||||||
error!("Repair failed: {e:?}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
debug!("Listing column families in database");
|
debug!("Listing column families in database");
|
||||||
|
@ -77,6 +75,7 @@ impl Engine {
|
||||||
|
|
||||||
let db = res.or_else(or_else)?;
|
let db = res.or_else(or_else)?;
|
||||||
info!(
|
info!(
|
||||||
|
columns = cfs.len(),
|
||||||
sequence = %db.latest_sequence_number(),
|
sequence = %db.latest_sequence_number(),
|
||||||
time = ?load_time.elapsed(),
|
time = ?load_time.elapsed(),
|
||||||
"Opened database."
|
"Opened database."
|
||||||
|
@ -243,6 +242,16 @@ impl Engine {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn repair(db_opts: &Options, path: &PathBuf) -> Result<()> {
|
||||||
|
warn!("Starting database repair. This may take a long time...");
|
||||||
|
match Db::repair(db_opts, path) {
|
||||||
|
Ok(()) => info!("Database repair successful."),
|
||||||
|
Err(e) => return Err!("Repair failed: {e:?}"),
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
impl Drop for Engine {
|
impl Drop for Engine {
|
||||||
#[cold]
|
#[cold]
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
|
@ -259,5 +268,10 @@ impl Drop for Engine {
|
||||||
|
|
||||||
debug!("Joining background threads...");
|
debug!("Joining background threads...");
|
||||||
self.env.join_all_threads();
|
self.env.join_all_threads();
|
||||||
|
|
||||||
|
info!(
|
||||||
|
sequence = %self.db.latest_sequence_number(),
|
||||||
|
"Closing database..."
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue