Skip to content
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
14 changes: 9 additions & 5 deletions crates/graphforge-api/src/repository.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2547,11 +2547,15 @@ mod tests {
.truncate(false)
.open(&path)
.unwrap_or_else(|error| panic!("{phase}: open {name}: {error}"));
assert!(
FileExt::try_lock_exclusive(&file)
.unwrap_or_else(|error| panic!("{phase}: try_lock {name}: {error}")),
"{phase}: {name} was still held (issue #275 probe)"
);
match FileExt::try_lock(&file) {
Ok(()) => {}
Err(fs4::TryLockError::WouldBlock) => {
panic!("{phase}: {name} was still held (issue #275 probe)")
}
Err(fs4::TryLockError::Error(error)) => {
panic!("{phase}: try_lock {name}: {error}")
}
}
FileExt::unlock(&file)
.unwrap_or_else(|error| panic!("{phase}: unlock {name}: {error}"));
}
Expand Down
25 changes: 15 additions & 10 deletions crates/graphforge-storage/src/project_checkpoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1846,18 +1846,21 @@ mod tests {
let checkpoint =
open_regular_lock(&worker_path).expect("phase=holder open checkpoints.lock");
let acquired = match mode {
CheckpointLockMode::Shared => FileExt::try_lock_shared(&checkpoint)
CheckpointLockMode::Shared => crate::file_lock::try_lock_shared(&checkpoint)
.expect("phase=holder acquire shared checkpoints.lock"),
CheckpointLockMode::Exclusive => FileExt::try_lock_exclusive(&checkpoint)
.expect("phase=holder acquire exclusive checkpoints.lock"),
CheckpointLockMode::Exclusive => {
crate::file_lock::try_lock_exclusive(&checkpoint)
.expect("phase=holder acquire exclusive checkpoints.lock")
}
};
assert!(
acquired,
"phase=holder checkpoints.lock unexpectedly busy mode={mode:?}"
);
ready_sender.send(()).expect("phase=holder publish ready");
release_receiver.recv().expect("phase=holder await release");
FileExt::unlock(&checkpoint).expect("phase=holder release checkpoints.lock");
crate::file_lock::unlock(&checkpoint)
.expect("phase=holder release checkpoints.lock");
})
.expect("phase=holder spawn");
let holder = WriterLockHolder {
Expand Down Expand Up @@ -1902,20 +1905,22 @@ mod tests {
let writer =
open_regular_lock(&worker_writer).expect("phase=holder open writer.lock");
assert!(
FileExt::try_lock_exclusive(&writer).expect("phase=holder acquire writer.lock"),
crate::file_lock::try_lock_exclusive(&writer)
.expect("phase=holder acquire writer.lock"),
"phase=holder writer.lock unexpectedly busy"
);
let checkpoint = open_regular_lock(&worker_checkpoint)
.expect("phase=holder open checkpoints.lock");
assert!(
FileExt::try_lock_exclusive(&checkpoint)
crate::file_lock::try_lock_exclusive(&checkpoint)
.expect("phase=holder acquire checkpoints.lock"),
"phase=holder checkpoints.lock unexpectedly busy"
);
FileExt::unlock(&writer).expect("phase=holder early release writer.lock");
crate::file_lock::unlock(&writer).expect("phase=holder early release writer.lock");
ready_sender.send(()).expect("phase=holder publish ready");
release_receiver.recv().expect("phase=holder await release");
FileExt::unlock(&checkpoint).expect("phase=holder release checkpoints.lock");
crate::file_lock::unlock(&checkpoint)
.expect("phase=holder release checkpoints.lock");
})
.expect("phase=holder spawn");
let holder = WriterLockHolder {
Expand Down Expand Up @@ -1948,10 +1953,10 @@ mod tests {
for name in [WRITER_LOCK_FILE, CHECKPOINT_LOCK_FILE] {
let lock = open_regular_lock(&lock_root.join(name)).unwrap();
assert!(
FileExt::try_lock_exclusive(&lock).unwrap(),
crate::file_lock::try_lock_exclusive(&lock).unwrap(),
"{phase}: {name} leaked"
);
FileExt::unlock(&lock).unwrap();
crate::file_lock::unlock(&lock).unwrap();
}
}

Expand Down