verify: acquire shared snapshot flock and skip on error
If we can't acquire a lock (either because the snapshot disappeared, it is about to be forgotten/pruned, or it is currently still running) skip the snapshot. Hold the lock during verification, so that it cannot be deleted while we are still verifying. Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
This commit is contained in:
parent
238a872d1f
commit
bfa54f2e85
@ -23,6 +23,7 @@ use crate::{
|
|||||||
task::TaskState,
|
task::TaskState,
|
||||||
task_log,
|
task_log,
|
||||||
tools::ParallelHandler,
|
tools::ParallelHandler,
|
||||||
|
tools::fs::lock_dir_noblock_shared,
|
||||||
};
|
};
|
||||||
|
|
||||||
fn verify_blob(datastore: Arc<DataStore>, backup_dir: &BackupDir, info: &FileInfo) -> Result<(), Error> {
|
fn verify_blob(datastore: Arc<DataStore>, backup_dir: &BackupDir, info: &FileInfo) -> Result<(), Error> {
|
||||||
@ -284,6 +285,21 @@ pub fn verify_backup_dir(
|
|||||||
upid: UPID,
|
upid: UPID,
|
||||||
) -> Result<bool, Error> {
|
) -> Result<bool, Error> {
|
||||||
|
|
||||||
|
let _guard_res = lock_dir_noblock_shared(
|
||||||
|
&datastore.snapshot_path(&backup_dir),
|
||||||
|
"snapshot",
|
||||||
|
"locked by another operation");
|
||||||
|
if let Err(err) = _guard_res {
|
||||||
|
task_log!(
|
||||||
|
worker,
|
||||||
|
"SKIPPED: verify {}:{} - could not acquire snapshot lock: {}",
|
||||||
|
datastore.name(),
|
||||||
|
backup_dir,
|
||||||
|
err,
|
||||||
|
);
|
||||||
|
return Ok(true);
|
||||||
|
}
|
||||||
|
|
||||||
let mut manifest = match datastore.load_manifest(&backup_dir) {
|
let mut manifest = match datastore.load_manifest(&backup_dir) {
|
||||||
Ok((manifest, _)) => manifest,
|
Ok((manifest, _)) => manifest,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user