Skip to content

Commit

Permalink
fix panic in object deleter (openzfs#31)
Browse files Browse the repository at this point in the history
In the delete_task(), tx.send() may find that the receiver has already
been dropped because the ObjectDeleter has been dropped.  This is not a
bug, we can ignore it and return from the deletion task.
  • Loading branch information
ahrens committed Dec 1, 2021
1 parent 34a60be commit 24d8a09
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions cmd/zfs_object_agent/zettaobject/src/object_deleter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl ObjectDeleter {
Self::open(object_access, guid, Default::default())
}

async fn deleter(
async fn delete_task(
object_access: Arc<ObjectAccess>,
guid: PoolGuid,
mut rx: mpsc::UnboundedReceiver<Vec<ObjectId>>,
Expand All @@ -46,7 +46,10 @@ impl ObjectDeleter {
vec.into_iter().map(|o| DataObject::key(guid, o)),
))
.await;
tx.send(chunk.len()).unwrap();
if tx.send(chunk.len()).is_err() {
// ObjectDeleter has been dropped
return;
}
}
info!(
"reclaim: deleted {} objects in {}ms",
Expand All @@ -72,7 +75,7 @@ impl ObjectDeleter {
};

if !object_access.readonly() {
tokio::spawn(Self::deleter(
tokio::spawn(Self::delete_task(
object_access,
guid,
initiation_rx,
Expand Down

0 comments on commit 24d8a09

Please sign in to comment.