diff --git a/src/database/abstraction/rocksdb.rs b/src/database/abstraction/rocksdb.rs index ea44919d..818ac05d 100644 --- a/src/database/abstraction/rocksdb.rs +++ b/src/database/abstraction/rocksdb.rs @@ -7,6 +7,7 @@ use std::{ }; use rocksdb::LogLevel::{Debug, Error, Fatal, Info, Warn}; +use tracing::debug; pub(crate) struct Engine { rocks: rocksdb::DBWithThreadMode, @@ -98,12 +99,15 @@ impl KeyValueDatabaseEngine for Arc { let db_opts = db_options(&rocksdb_cache, config); + debug!("Listing column families in database"); let cfs = rocksdb::DBWithThreadMode::::list_cf( &db_opts, &config.database_path, ) .unwrap_or_default(); + debug!("Opening column family descriptors in database"); + info!("RocksDB database compaction will take place now, a delay in startup is expected"); let db = rocksdb::DBWithThreadMode::::open_cf_descriptors( &db_opts, &config.database_path, @@ -123,6 +127,7 @@ impl KeyValueDatabaseEngine for Arc { fn open_tree(&self, name: &'static str) -> Result> { if !self.old_cfs.contains(&name.to_owned()) { // Create if it didn't exist + debug!("Creating new column family in database: {}", name); let _ = self .rocks .create_cf(name, &db_options(&self.cache, &self.config)); diff --git a/src/database/mod.rs b/src/database/mod.rs index 26e9ea31..4af64351 100644 --- a/src/database/mod.rs +++ b/src/database/mod.rs @@ -222,20 +222,23 @@ impl KeyValueDatabase { Self::check_db_setup(&config)?; if !Path::new(&config.database_path).exists() { + debug!("Database path does not exist, assuming this is a new setup and creating it"); std::fs::create_dir_all(&config.database_path) .map_err(|e| { error!("Failed to create database path: {e}"); - Error::BadConfig("Database folder doesn't exists and couldn't be created (e.g. due to missing permissions). Please create the database folder yourself.")})?; + Error::BadConfig("Database folder doesn't exists and couldn't be created (e.g. due to missing permissions). Please create the database folder yourself or allow conduwuit the permissions to create directories and files.")})?; } let builder: Arc = match &*config.database_backend { "sqlite" => { + debug!("Got sqlite database backend"); #[cfg(not(feature = "sqlite"))] return Err(Error::BadConfig("Database backend not found.")); #[cfg(feature = "sqlite")] Arc::new(Arc::::open(&config)?) } "rocksdb" => { + debug!("Got rocksdb database backend"); #[cfg(not(feature = "rocksdb"))] return Err(Error::BadConfig("Database backend not found.")); #[cfg(feature = "rocksdb")] @@ -1053,7 +1056,6 @@ impl KeyValueDatabase { Ok(()) } - #[tracing::instrument(skip(self))] pub fn flush(&self) -> Result<()> { let start = std::time::Instant::now(); diff --git a/src/main.rs b/src/main.rs index ccad9128..fd8e4838 100644 --- a/src/main.rs +++ b/src/main.rs @@ -144,10 +144,12 @@ async fn main() { }; info!("Loading database"); + let db_load_time = std::time::Instant::now(); if let Err(error) = KeyValueDatabase::load_or_create(config).await { error!(?error, "The database couldn't be loaded or created"); return; }; + info!("Database took {:?} to load", db_load_time.elapsed()); let config = &services().globals.config;