ok/jj
1
0
Fork 0
forked from mirrors/jj

tests: fix concurrent git read/write test to retry on ref lock contention

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 b37293fa68 "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
This commit is contained in:
Yuya Nishihara 2024-02-17 11:55:04 +09:00
parent ce295f8bc2
commit 5eea88d26a

View file

@ -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;
@ -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();