From 231cb32955080557b05c7dde7d7adee664457e0e Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Wed, 22 Apr 2020 19:25:15 +0000 Subject: Do not delete block if just a single replication error. Write TODO stuff. --- src/block.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/block.rs b/src/block.rs index 46abcf02..6c785f89 100644 --- a/src/block.rs +++ b/src/block.rs @@ -278,25 +278,25 @@ impl BlockManager { let who_needs = join_all(who_needs_fut).await; let mut need_nodes = vec![]; - let mut errors = 0; for (node, needed) in who.into_iter().zip(who_needs.iter()) { match needed { Ok(Message::NeedBlockReply(true)) => { need_nodes.push(node); } - Err(_) => { - errors += 1; + Err(e) => { + return Err(Error::Message(format!( + "Should delete block, but unable to confirm that all other nodes that need it have it: {}", + e + ))); + } + _ => { + return Err(Error::Message(format!( + "Unexpected response to NeedBlockQuery RPC" + ))); } - _ => (), } } - if errors > (garage.system.config.data_replication_factor - 1) / 2 { - return Err(Error::Message(format!( - "Should delete block, but not enough nodes confirm that they have it." - ))); - } - if need_nodes.len() > 0 { let put_block_message = self.read_block(hash).await?; let put_responses = self -- cgit v1.2.3