aboutsummaryrefslogtreecommitdiff
path: root/src/block/resync.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-12-13 15:02:42 +0100
committerAlex Auvolat <alex@adnab.me>2022-12-13 15:02:42 +0100
commitd7f90cabb0517a50a6c3dd702852770240566bfc (patch)
tree5c6f99f1dfb6c3187a1dd28a507b88c65a8dc039 /src/block/resync.rs
parent687660b27f904422c689e09d2457293e5313d325 (diff)
downloadgarage-d7f90cabb0517a50a6c3dd702852770240566bfc.tar.gz
garage-d7f90cabb0517a50a6c3dd702852770240566bfc.zip
Implement `block retry-now` and `block purge`
Diffstat (limited to 'src/block/resync.rs')
-rw-r--r--src/block/resync.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/block/resync.rs b/src/block/resync.rs
index 53b44774..8231b55d 100644
--- a/src/block/resync.rs
+++ b/src/block/resync.rs
@@ -123,6 +123,24 @@ impl BlockResyncManager {
Ok(self.errors.len())
}
+ /// Clear the error counter for a block and put it in queue immediately
+ pub fn clear_backoff(&self, hash: &Hash) -> Result<(), Error> {
+ let now = now_msec();
+ if let Some(ec) = self.errors.get(hash)? {
+ let mut ec = ErrorCounter::decode(&ec);
+ if ec.errors > 0 {
+ ec.last_try = now - ec.delay_msec();
+ self.errors.insert(hash, ec.encode())?;
+ self.put_to_resync_at(hash, now)?;
+ return Ok(());
+ }
+ }
+ Err(Error::Message(format!(
+ "Block {:?} was not in an errored state",
+ hash
+ )))
+ }
+
// ---- Resync loop ----
// This part manages a queue of blocks that need to be