Skip to content

Commit

Permalink
tests: fix concurrent git read/write test to retry on ref lock conten…
Browse files Browse the repository at this point in the history
…tion

Apparently, gix has 100ms timeout. Since this test tries to create contended
situation, it's possible that the ref lock can't be acquired. I've added
upper bound to the retry loop at b37293f "tests: add upper bound to
test_concurrent_read_write_commit() loop", so ignoring arbitrary errors
should be okay.

The problem can be reproduced on my Linux machine by inserting 10ms sleep() to
gix and increasing the concurrency.

Fixes #3069
  • Loading branch information
yuja committed Feb 17, 2024
1 parent ce295f8 commit e0974b4
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/tests/test_git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use std::collections::{BTreeMap, HashSet};
use std::path::PathBuf;
use std::sync::{mpsc, Arc, Barrier};
use std::{fs, thread};
use std::{fs, iter, thread};

use assert_matches::assert_matches;
use git2::Oid;
Expand Down Expand Up @@ -2928,7 +2928,17 @@ fn test_concurrent_read_write_commit() {
None
}
Err(BackendError::ObjectNotFound { .. }) => Some(commit_id),
Err(err) => panic!("unexpected error: {err}"),
Err(err) => {
eprintln!(
"import error in reader {i} (maybe lock contention?): {}",
iter::successors(
Some(&err as &dyn std::error::Error),
|e| e.source(),
)
.join(": ")
);
Some(commit_id)
}
}
})
.collect_vec();
Expand Down

0 comments on commit e0974b4

Please sign in to comment.