From d726cf02997417f6f03ce2fe6e7d7886204cb633 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Sun, 14 Sep 2025 19:34:44 +0200 Subject: [PATCH] add `garage repair clear-resync-queue` (fix #1151) --- src/block/resync.rs | 8 ++++++++ src/garage/cli/structs.rs | 4 ++++ src/garage/repair/online.rs | 5 +++++ 3 files changed, 17 insertions(+) diff --git a/src/block/resync.rs b/src/block/resync.rs index 004f6b48..7056a828 100644 --- a/src/block/resync.rs +++ b/src/block/resync.rs @@ -133,6 +133,14 @@ impl BlockResyncManager { ))) } + /// Clear the entire resync queue and list of errored blocks + /// Corresponds to `garage repair clear-resync-queue` + pub fn clear_resync_queue(&self) -> Result<(), Error> { + self.queue.clear()?; + self.errors.clear()?; + Ok(()) + } + pub fn register_bg_vars(&self, vars: &mut vars::BgVars) { let notify = self.notify.clone(); vars.register_rw( diff --git a/src/garage/cli/structs.rs b/src/garage/cli/structs.rs index 3652ef6b..386a213b 100644 --- a/src/garage/cli/structs.rs +++ b/src/garage/cli/structs.rs @@ -466,6 +466,10 @@ pub enum RepairWhat { /// Repair (resync/rebalance) the set of stored blocks in the cluster #[structopt(name = "blocks", version = garage_version())] Blocks, + /// Clear the block resync queue. The list of blocks in errored state + /// is cleared as well. You MUST run `garage repair blocks` after invoking this. + #[structopt(name = "clear-resync-queue", version = garage_version())] + ClearResyncQueue, /// Repropagate object deletions to the version table #[structopt(name = "versions", version = garage_version())] Versions, diff --git a/src/garage/repair/online.rs b/src/garage/repair/online.rs index 950cd5f7..6a7dafcf 100644 --- a/src/garage/repair/online.rs +++ b/src/garage/repair/online.rs @@ -92,6 +92,11 @@ pub async fn launch_online_repair( info!("Repairing bucket aliases (foreground)"); garage.locked_helper().await.repair_aliases().await?; } + RepairWhat::ClearResyncQueue => { + let garage = garage.clone(); + tokio::task::spawn_blocking(move || garage.block_manager.resync.clear_resync_queue()) + .await?? + } } Ok(()) }