Skip to content

Commit

Permalink
fix(SweepObjects): dedup backend checking
Browse files Browse the repository at this point in the history
To prevent same backend from being checked multiple times
  • Loading branch information
iwanbk committed Nov 29, 2024
1 parent cd24f42 commit b3a86a9
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions zstor/src/actors/repairer.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -79,13 +83,21 @@ impl Handler<SweepObjects> 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<ZdbConnectionInfo> = metadata
.shards()
.iter()
.map(|shard_info| shard_info.zdb())
.cloned()
.collect::<Vec<_>>();
.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,
Expand Down

0 comments on commit b3a86a9

Please sign in to comment.