From f5d6ea1623693fdbc9155b705d6ed84306ff4267 Mon Sep 17 00:00:00 2001 From: overtrue <1472352+overtrue@users.noreply.github.com> Date: Wed, 2 Dec 2026 02:53:05 +0000 Subject: [PATCH] test(ecstore): check replica lock ordering during publication --- .../tests/metadata_read_lock_reuse_test.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/crates/ecstore/tests/metadata_read_lock_reuse_test.rs b/crates/ecstore/tests/metadata_read_lock_reuse_test.rs index 1ce4f6875b..24076f86f9 100644 --- a/crates/ecstore/tests/metadata_read_lock_reuse_test.rs +++ b/crates/ecstore/tests/metadata_read_lock_reuse_test.rs @@ -308,12 +308,12 @@ async fn replica_write_with_waiting_metadata_writer(multipart: bool) { .new_ns_lock(".rustfs.sys", &format!("bucket-targets/{bucket}/transaction.lock")) .await .expect("create metadata writer"); - let writer = lock.get_write_lock(Duration::from_secs(5)); + let writer = lock.get_write_lock(Duration::from_secs(30)); tokio::pin!(writer); // Leave the writer registered while the replica continues. A second read // acquisition would queue behind this writer, which needs our first read. assert!(futures::poll!(&mut writer).is_pending()); - timeout(Duration::from_secs(2), async { + let commit = async { if let Some((upload_id, parts)) = upload { store .clone() @@ -323,10 +323,13 @@ async fn replica_write_with_waiting_metadata_writer(multipart: bool) { let mut data = PutObjReader::from_vec(b"replicated version".to_vec()); store.put_object(bucket, "object", &mut data, &opts).await } - }) - .await - .expect("replica must reuse its metadata read lock instead of waiting behind the writer") - .expect("replica PUT should commit"); + }; + // The queued writer bounds a recursive read. Disk publication may take longer on a busy filesystem. + tokio::select! { + biased; + _ = &mut writer => panic!("metadata writer finished before the replica committed under its snapshot"), + result = commit => result.expect("replica PUT should commit"), + }; assert!(futures::poll!(&mut writer).is_pending(), "the snapshot must still fence metadata updates"); let read_opts = ObjectOptions { version_id: opts.version_id.clone(),