From e0974b440fdb7e591a00cf6753e36011603c5691 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Sat, 17 Feb 2024 11:55:04 +0900 Subject: [PATCH] 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 b37293fa683c "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 --- lib/tests/test_git.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/tests/test_git.rs b/lib/tests/test_git.rs index dc4eba52bf..5bdf2c0970 100644 --- a/lib/tests/test_git.rs +++ b/lib/tests/test_git.rs @@ -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();