Skip to content

Commit

Permalink
fix: create a more local lock when creating writable fixtures.
Browse files Browse the repository at this point in the history
Previously, the lock location would block all writers from executing
a fixture even though they wouldn't step on each others feet.

Now, a script destination is used to assure locks are created close
to the destination when creating writable fixtures, typically removing
the need for multiple writers to wait on each other unnecessarily.
  • Loading branch information
Byron committed Dec 5, 2024
1 parent e614437 commit ad9d484
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions tests/tools/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,11 +509,18 @@ fn scripted_fixture_read_only_with_args_inner(
|d| (true, d.to_owned()),
);

let _marker = gix_lock::Marker::acquire_to_hold_resource(
script_basename,
gix_lock::acquire::Fail::AfterDurationWithBackoff(Duration::from_secs(6 * 60)),
None,
)?;
// We may that destination_dir is already unique (i.e. temp-dir) - thus there is no need for a lock,
// and we can execute scripts in parallel.
let _marker = destination_dir
.is_none()
.then(|| {
gix_lock::Marker::acquire_to_hold_resource(
script_basename,
gix_lock::acquire::Fail::AfterDurationWithBackoff(Duration::from_secs(6 * 60)),
None,
)
})
.transpose()?;
let failure_marker = script_result_directory.join("_invalid_state_due_to_script_failure_");
if force_run || !script_result_directory.is_dir() || failure_marker.is_file() {
if failure_marker.is_file() {
Expand Down

0 comments on commit ad9d484

Please sign in to comment.