From b3a86a9ff0e95b4d6badc8e7e095a302687b8faf Mon Sep 17 00:00:00 2001 From: Iwan BK Date: Fri, 29 Nov 2024 20:50:06 +0700 Subject: [PATCH] fix(SweepObjects): dedup backend checking To prevent same backend from being checked multiple times --- zstor/src/actors/repairer.rs | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/zstor/src/actors/repairer.rs b/zstor/src/actors/repairer.rs index 0957a12..c8cd591 100644 --- a/zstor/src/actors/repairer.rs +++ b/zstor/src/actors/repairer.rs @@ -1,10 +1,14 @@ -use crate::actors::{ - backends::{BackendManagerActor, RequestBackends, StateInterest}, - meta::{MetaStoreActor, ObjectMetas}, - zstor::{Rebuild, ZstorActor}, +use crate::{ + actors::{ + backends::{BackendManagerActor, RequestBackends, StateInterest}, + meta::{MetaStoreActor, ObjectMetas}, + zstor::{Rebuild, ZstorActor}, + }, + zdb::ZdbConnectionInfo, }; use actix::prelude::*; -use log::{error, warn}; +use log::{debug, error, warn}; +use std::collections::HashSet; use std::time::Duration; /// Amount of time between starting a new sweep of the backend objects. @@ -79,13 +83,21 @@ impl Handler for RepairActor { }, }; + // prevent same backend from being checked multiple times + let mut unique_zdbs = HashSet::new(); for (key, metadata) in obj_metas.into_iter() { - let backend_requests = metadata + let backend_requests: Vec = metadata .shards() .iter() - .map(|shard_info| shard_info.zdb()) - .cloned() - .collect::>(); + .map(|shard_info| shard_info.zdb().clone()) + .filter(|zdb| unique_zdbs.insert(zdb.clone())) + .collect(); + if backend_requests.is_empty() { + debug!("No unchecked backends found for object: {}", key); + continue; + } + debug!("number of backends to check = {}", backend_requests.len()); + let backends = match backend_manager .send(RequestBackends { backend_requests,