diff options
author | Alex Auvolat <alex@adnab.me> | 2022-12-14 11:58:06 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2022-12-14 11:58:06 +0100 |
commit | 83c8467e23c1f531ae233766d5dc7244afe57f08 (patch) | |
tree | d2f959bccc6c779917ce64bee2b2f1cc236164db /src/model/s3/version_table.rs | |
parent | f8e528c15de0c9d31c16e5cd8e58f99f4132f103 (diff) | |
download | garage-83c8467e23c1f531ae233766d5dc7244afe57f08.tar.gz garage-83c8467e23c1f531ae233766d5dc7244afe57f08.zip |
Proper queueing for delayed inserts, now backed to disk
Diffstat (limited to 'src/model/s3/version_table.rs')
-rw-r--r-- | src/model/s3/version_table.rs | 37 |
1 files changed, 15 insertions, 22 deletions
diff --git a/src/model/s3/version_table.rs b/src/model/s3/version_table.rs index 6bc2ecd1..0cfaa954 100644 --- a/src/model/s3/version_table.rs +++ b/src/model/s3/version_table.rs @@ -141,33 +141,26 @@ impl TableSchema for VersionTable { fn updated( &self, - _tx: &mut db::Transaction, + tx: &mut db::Transaction, old: Option<&Self::E>, new: Option<&Self::E>, ) -> db::TxOpResult<()> { - let block_ref_table = self.block_ref_table.clone(); - let old = old.cloned(); - let new = new.cloned(); - - self.background.spawn(async move { - if let (Some(old_v), Some(new_v)) = (old, new) { - // Propagate deletion of version blocks - if new_v.deleted.get() && !old_v.deleted.get() { - let deleted_block_refs = old_v - .blocks - .items() - .iter() - .map(|(_k, vb)| BlockRef { - block: vb.hash, - version: old_v.uuid, - deleted: true.into(), - }) - .collect::<Vec<_>>(); - block_ref_table.insert_many(&deleted_block_refs[..]).await?; + if let (Some(old_v), Some(new_v)) = (old, new) { + // Propagate deletion of version blocks + if new_v.deleted.get() && !old_v.deleted.get() { + let deleted_block_refs = old_v.blocks.items().iter().map(|(_k, vb)| BlockRef { + block: vb.hash, + version: old_v.uuid, + deleted: true.into(), + }); + for block_ref in deleted_block_refs { + let res = self.block_ref_table.queue_insert(tx, &block_ref); + if let Err(e) = db::unabort(res)? { + error!("Unable to enqueue block ref deletion propagation: {}. A repair will be needed.", e); + } } } - Ok(()) - }); + } Ok(()) } |