aboutsummaryrefslogtreecommitdiff
path: root/src/version_table.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2020-04-19 20:52:20 +0000
committerAlex Auvolat <alex@adnab.me>2020-04-19 20:52:20 +0000
commit04acaea231a9af77e5ca05068336f4492fe32ac0 (patch)
tree412a346fed1a24b861a90c9a3e527e46f050ffa0 /src/version_table.rs
parent5ae32972efaba357ecc0027fe852d710b16b6d0e (diff)
downloadgarage-04acaea231a9af77e5ca05068336f4492fe32ac0.tar.gz
garage-04acaea231a9af77e5ca05068336f4492fe32ac0.zip
Don't do version & block_ref updates in background on deletion
Diffstat (limited to 'src/version_table.rs')
-rw-r--r--src/version_table.rs31
1 files changed, 15 insertions, 16 deletions
diff --git a/src/version_table.rs b/src/version_table.rs
index dfd27812..230b7f1c 100644
--- a/src/version_table.rs
+++ b/src/version_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::*;
@@ -67,26 +68,24 @@ impl TableSchema for VersionTable {
type E = Version;
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 block_ref_table = self.block_ref_table.clone();
if let (Some(old_v), Some(new_v)) = (old, new) {
// Propagate deletion of version blocks
- self.background.spawn(async move {
- if new_v.deleted && !old_v.deleted {
- let deleted_block_refs = old_v
- .blocks
- .iter()
- .map(|vb| BlockRef {
- block: vb.hash.clone(),
- version: old_v.uuid.clone(),
- deleted: true,
- })
- .collect::<Vec<_>>();
- block_ref_table.insert_many(&deleted_block_refs[..]).await?;
- }
- Ok(())
- });
+ if new_v.deleted && !old_v.deleted {
+ let deleted_block_refs = old_v
+ .blocks
+ .iter()
+ .map(|vb| BlockRef {
+ block: vb.hash.clone(),
+ version: old_v.uuid.clone(),
+ deleted: true,
+ })
+ .collect::<Vec<_>>();
+ block_ref_table.insert_many(&deleted_block_refs[..]).await?;
+ }
}
+ Ok(())
}
fn matches_filter(entry: &Self::E, _filter: &Self::Filter) -> bool {