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

Remove redundant log message in backup #277

Merged
merged 1 commit into from
May 14, 2024
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ Versioning](https://semver.org/spec/v2.0.0.html).
with other database table type definitions.
- Changed the return type of `Store::account_policy_map` to `Table<AccountPlicy>`
to enhance security by preventing direct exposure of internal structure.
- Removed redundant log messages in the backup module. Errors are now reported
through return values only, allowing callers to handle and log errors
according to their needs.

### Removed

Expand Down
39 changes: 8 additions & 31 deletions src/backup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use rocksdb::backup::BackupEngineInfo;
use std::sync::Arc;
use tokio::sync::RwLock;
use tracing::{info, warn};

#[allow(clippy::module_name_repetitions)]
pub struct BackupInfo {
Expand All @@ -32,21 +31,8 @@
/// Returns an error if backup fails.
pub async fn create(store: &Arc<RwLock<Store>>, flush: bool, backups_to_keep: u32) -> Result<()> {
// TODO: This function should be expanded to support PostgreSQL backups as well.
info!("backing up database...");
let res = {
let mut store = store.write().await;
store.backup(flush, backups_to_keep)
};
match res {
Ok(()) => {
info!("backing up database completed");
Ok(())
}
Err(e) => {
warn!("database backup failed: {:?}", e);
Err(e)
}
}
let mut store = store.write().await;
store.backup(flush, backups_to_keep)

Check warning on line 35 in src/backup.rs

View check run for this annotation

Codecov / codecov/patch

src/backup.rs#L34-L35

Added lines #L34 - L35 were not covered by tests
}

/// Lists the backup information of the database.
Expand All @@ -56,23 +42,14 @@
/// Returns an error if backup list fails to create
pub async fn list(store: &Arc<RwLock<Store>>) -> Result<Vec<BackupInfo>> {
// TODO: This function should be expanded to support PostgreSQL backups as well.
let res = {
let backup_list = {
let store = store.read().await;
store.get_backup_info()
store.get_backup_info()?
};
match res {
Ok(backup_list) => {
info!("generate database backup list");
Ok(backup_list
.into_iter()
.map(std::convert::Into::into)
.collect())
}
Err(e) => {
warn!("failed to generate backup list: {:?}", e);
Err(e)
}
}
Ok(backup_list
.into_iter()
.map(std::convert::Into::into)
.collect())
}

/// Restores the database from a backup with the specified ID.
Expand Down