diff options
author | Alex Auvolat <alex@adnab.me> | 2020-04-19 20:52:20 +0000 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2020-04-19 20:52:20 +0000 |
commit | 04acaea231a9af77e5ca05068336f4492fe32ac0 (patch) | |
tree | 412a346fed1a24b861a90c9a3e527e46f050ffa0 /src/object_table.rs | |
parent | 5ae32972efaba357ecc0027fe852d710b16b6d0e (diff) | |
download | garage-04acaea231a9af77e5ca05068336f4492fe32ac0.tar.gz garage-04acaea231a9af77e5ca05068336f4492fe32ac0.zip |
Don't do version & block_ref updates in background on deletion
Diffstat (limited to 'src/object_table.rs')
-rw-r--r-- | src/object_table.rs | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/src/object_table.rs b/src/object_table.rs index 59ce3b7f..0d0de146 100644 --- a/src/object_table.rs +++ b/src/object_table.rs @@ -4,6 +4,7 @@ use std::sync::Arc; use crate::background::BackgroundRunner; use crate::data::*; +use crate::error::Error; use crate::table::*; use crate::table_sharded::*; @@ -101,30 +102,28 @@ impl TableSchema for ObjectTable { type E = Object; type Filter = (); - async fn updated(&self, old: Option<Self::E>, new: Option<Self::E>) { + async fn updated(&self, old: Option<Self::E>, new: Option<Self::E>) -> Result<(), Error> { let version_table = self.version_table.clone(); if let (Some(old_v), Some(new_v)) = (old, new) { // Propagate deletion of old versions - self.background.spawn(async move { - for v in old_v.versions.iter() { - if new_v - .versions - .binary_search_by(|nv| nv.cmp_key().cmp(&v.cmp_key())) - .is_err() - { - let deleted_version = Version { - uuid: v.uuid.clone(), - deleted: true, - blocks: vec![], - bucket: old_v.bucket.clone(), - key: old_v.key.clone(), - }; - version_table.insert(&deleted_version).await?; - } + for v in old_v.versions.iter() { + if new_v + .versions + .binary_search_by(|nv| nv.cmp_key().cmp(&v.cmp_key())) + .is_err() + { + let deleted_version = Version { + uuid: v.uuid.clone(), + deleted: true, + blocks: vec![], + bucket: old_v.bucket.clone(), + key: old_v.key.clone(), + }; + version_table.insert(&deleted_version).await?; } - Ok(()) - }); + } } + Ok(()) } fn matches_filter(_entry: &Self::E, _filter: &Self::Filter) -> bool { |