Skip to content
Snippets Groups Projects
Commit a74613be authored by Jason Volk's avatar Jason Volk Committed by Jason Volk
Browse files

improve database repair/shutdown log messages


Signed-off-by: default avatarJason Volk <jason@zemos.net>
parent a95ded16
No related branches found
No related tags found
No related merge requests found
use std::{
collections::{BTreeSet, HashMap},
fmt::Write,
path::PathBuf,
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::{
backup::{BackupEngine, BackupEngineOptions},
perf::get_memory_usage_stats,
......@@ -50,10 +51,7 @@ pub(crate) fn open(server: &Arc<Server>) -> Result<Arc<Self>> {
let load_time = std::time::Instant::now();
if config.rocksdb_repair {
warn!("Starting database repair. This may take a long time...");
if let Err(e) = Db::repair(&db_opts, &config.database_path) {
error!("Repair failed: {e:?}");
}
repair(&db_opts, &config.database_path)?;
}
debug!("Listing column families in database");
......@@ -77,6 +75,7 @@ pub(crate) fn open(server: &Arc<Server>) -> Result<Arc<Self>> {
let db = res.or_else(or_else)?;
info!(
columns = cfs.len(),
sequence = %db.latest_sequence_number(),
time = ?load_time.elapsed(),
"Opened database."
......@@ -243,6 +242,16 @@ pub fn file_list(&self) -> Result<String> {
}
}
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 {
#[cold]
fn drop(&mut self) {
......@@ -259,5 +268,10 @@ fn drop(&mut self) {
debug!("Joining background threads...");
self.env.join_all_threads();
info!(
sequence = %self.db.latest_sequence_number(),
"Closing database..."
);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment