Do not delete block if just a single replication error. Write TODO stuff.

This commit is contained in:
Alex Auvolat
2020-04-22 19:25:15 +00:00
parent 8971f34c81
commit 231cb32955
2 changed files with 36 additions and 18 deletions
+10 -10
View File
@@ -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