Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

volume(rust): untrack queued writes before replying (#12595)

Chris Lua2b9b37ee543
diff --git a/seaweed-volume/src/server/write_queue.rs b/seaweed-volume/src/server/write_queue.rs
index 6286bc81c2..2398ec75d1 100644
--- a/seaweed-volume/src/server/write_queue.rs
+++ b/seaweed-volume/src/server/write_queue.rs
@@ -376,9 +376,10 @@ fn process_batch(state: Arc<VolumeServerState>, batch: Vec<WriteRequest>) {
for (needle, fsync, response_tx, pending) in entries {
// A delete reaching a remounted volume cannot cancel a write
// queued for the old one.
- if let (Ok(vol), Some(pending)) = (&vol, &pending)
- && !vol.tracks_pending_write(pending)
+ if let (Ok(vol), Some(tracked)) = (&vol, &pending)
+ && !vol.tracks_pending_write(tracked)
{
+ drop(pending);
let _ = response_tx.send(Err(VolumeError::NotFound));
continue;
}
@@ -396,6 +397,9 @@ fn process_batch(state: Arc<VolumeServerState>, batch: Vec<WriteRequest>) {
})
.collect(),
};
+ // Untrack before replying, as Go does: a caller that sees its write
+ // finish must not still find it pending.
+ drop(pendings);
for (response_tx, result) in senders.into_iter().zip(results) {
// Send result back; ignore error if receiver dropped.
let _ = response_tx.send(result);