block resync: avoid saving blocks to draining nodes
Some checks failed
ci/woodpecker/push/debug Pipeline failed
ci/woodpecker/pr/debug Pipeline failed

This commit is contained in:
Alex 2025-02-14 16:27:12 +01:00
parent c36ba67b32
commit ff9815cb90

View file

@ -377,7 +377,10 @@ impl BlockResyncManager {
info!("Resync block {:?}: offloading and deleting", hash);
let existing_path = existing_path.unwrap();
let mut who = manager.replication.storage_nodes(hash);
let mut who = manager
.system
.cluster_layout()
.current_storage_nodes_of(hash);
if who.len() < manager.replication.write_quorum() {
return Err(Error::Message("Not trying to offload block because we don't have a quorum of nodes to write to".to_string()));
}
@ -455,6 +458,21 @@ impl BlockResyncManager {
}
if rc.is_nonzero() && !exists {
// The refcount is > 0, and the block is not present locally.
// First, check whether
let storage_nodes = manager
.system
.cluster_layout()
.current_storage_nodes_of(&hash);
if !storage_nodes.contains(&manager.system.id) {
info!(
"Resync block {:?}: block is absent with refcount > 0, but it will drop to zero after all metadata is synced. Not fetching the block.",
hash
);
return Ok(());
}
info!(
"Resync block {:?}: fetching absent but needed block (refcount > 0)",
hash