add error case for layout not ready, and fail earlier in many places

This commit is contained in:
Alex Auvolat
2025-09-13 20:24:19 +02:00
parent 4758d8881f
commit 4c139bcbca
23 changed files with 323 additions and 244 deletions
+5 -8
View File
@@ -285,7 +285,7 @@ impl BlockManager {
let who = self
.system
.rpc_helper()
.block_read_nodes_of(hash, self.system.rpc_helper());
.block_read_nodes_of(hash, self.system.rpc_helper())?;
for node in who.iter() {
let node_id = NodeID::from(*node);
@@ -341,12 +341,9 @@ impl BlockManager {
/// layout version only: since blocks are immutable, we don't need to
/// do complex logic when several layour versions are active at once,
/// just move them directly to the new nodes.
pub(crate) fn storage_nodes_of(&self, hash: &Hash) -> Vec<Uuid> {
self.system
.cluster_layout()
.current()
.nodes_of(hash)
.collect()
pub(crate) fn storage_nodes_of(&self, hash: &Hash) -> Result<Vec<Uuid>, Error> {
let cluster_layout = self.system.cluster_layout();
Ok(cluster_layout.current()?.nodes_of(hash).collect())
}
// ---- Public interface ----
@@ -381,7 +378,7 @@ impl BlockManager {
prevent_compression: bool,
order_tag: Option<OrderTag>,
) -> Result<(), Error> {
let who = self.storage_nodes_of(&hash);
let who = self.storage_nodes_of(&hash)?;
let compression_level = self.compression_level.filter(|_| !prevent_compression);
let (header, bytes) = DataBlock::from_buffer(data, compression_level)
+2 -2
View File
@@ -375,7 +375,7 @@ impl BlockResyncManager {
info!("Resync block {:?}: offloading and deleting", hash);
let existing_path = existing_path.unwrap();
let mut who = manager.storage_nodes_of(hash);
let mut who = manager.storage_nodes_of(hash)?;
if who.len() < manager.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()));
}
@@ -458,7 +458,7 @@ impl BlockResyncManager {
// First, check whether we are still supposed to store that
// block in the latest cluster layout version.
let storage_nodes = manager.storage_nodes_of(&hash);
let storage_nodes = manager.storage_nodes_of(&hash)?;
if !storage_nodes.contains(&manager.system.id) {
info!(