fix: reduce flakiness of lock_tracker_metrics test (#2238)

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
pull/24376/head
Raphael Taylor-Davies 2021-08-10 12:47:08 +01:00 committed by GitHub
parent b6364ec732
commit 29ac62c6f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -3747,15 +3747,21 @@ mod tests {
let chunks = db.catalog.chunks();
assert_eq!(chunks.len(), 1);
let (sender, receiver) = tokio::sync::oneshot::channel();
let chunk_a = Arc::clone(&chunks[0]);
let chunk_b = Arc::clone(&chunks[0]);
let chunk_b = chunk_b.write();
let task = tokio::spawn(async move {
sender.send(()).unwrap();
let _ = chunk_a.read();
});
// Wait for background task to reach lock
let _ = receiver.await.unwrap();
// Hold lock for 100 milliseconds blocking background task
std::thread::sleep(std::time::Duration::from_millis(100));