block/repair.rs: Added log entries for scrub start/finish. #551

Merged
lx merged 1 commit from jpds/garage:scrub-log into main 2023-04-24 08:29:37 +00:00

View file

@ -281,6 +281,7 @@ impl ScrubWorker {
ScrubWorkerCommand::Start => { ScrubWorkerCommand::Start => {
self.work = match std::mem::take(&mut self.work) { self.work = match std::mem::take(&mut self.work) {
ScrubWorkerState::Finished => { ScrubWorkerState::Finished => {
info!("Scrub worker initializing, now performing datastore scrub");
let iterator = BlockStoreIterator::new(&self.manager); let iterator = BlockStoreIterator::new(&self.manager);
ScrubWorkerState::Running(iterator) ScrubWorkerState::Running(iterator)
} }
@ -394,12 +395,21 @@ impl Worker for ScrubWorker {
.tranquilizer .tranquilizer
.tranquilize_worker(self.persister.get_with(|p| p.tranquility))) .tranquilize_worker(self.persister.get_with(|p| p.tranquility)))
} else { } else {
let now = now_msec();
let next_scrub_timestamp = randomize_next_scrub_run_time(now);
self.persister.set_with(|p| { self.persister.set_with(|p| {
p.time_last_complete_scrub = now_msec(); p.time_last_complete_scrub = now;
p.time_next_run_scrub = randomize_next_scrub_run_time(now_msec()); p.time_next_run_scrub = next_scrub_timestamp;
})?; })?;
self.work = ScrubWorkerState::Finished; self.work = ScrubWorkerState::Finished;
self.tranquilizer.clear(); self.tranquilizer.clear();
info!(
"Datastore scrub completed, next scrub scheduled for {}",
msec_to_rfc3339(next_scrub_timestamp)
);
Ok(WorkerState::Idle) Ok(WorkerState::Idle)
} }
} }