aboutsummaryrefslogtreecommitdiff
path: root/src/block/resync.rs
diff options
context:
space:
mode:
authorAlex <alex@adnab.me>2024-03-19 15:59:19 +0000
committerAlex <alex@adnab.me>2024-03-19 15:59:19 +0000
commit65853a48634d662809eee5dafbe48535d400f4a0 (patch)
tree3bb01998fa81651a54ade8bf17ba87b5a3eff970 /src/block/resync.rs
parent0038ca8a78f147b9c0ec07ef0121773aaf110dc9 (diff)
parent3eab639c146f67fc67534633ae26c9aec116327d (diff)
downloadgarage-65853a48634d662809eee5dafbe48535d400f4a0.tar.gz
garage-65853a48634d662809eee5dafbe48535d400f4a0.zip
Merge pull request 'block refcount repair' (#782) from block-ref-repair into next-0.10
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/782
Diffstat (limited to 'src/block/resync.rs')
-rw-r--r--src/block/resync.rs17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/block/resync.rs b/src/block/resync.rs
index 48c2cef1..b4108213 100644
--- a/src/block/resync.rs
+++ b/src/block/resync.rs
@@ -367,6 +367,13 @@ impl BlockResyncManager {
}
if exists && rc.is_deletable() {
+ if manager.rc.recalculate_rc(hash)?.0 > 0 {
+ return Err(Error::Message(format!(
+ "Refcount for block {:?} was inconsistent, retrying later",
+ hash
+ )));
+ }
+
info!("Resync block {:?}: offloading and deleting", hash);
let existing_path = existing_path.unwrap();
@@ -453,7 +460,15 @@ impl BlockResyncManager {
hash
);
- let block_data = manager.rpc_get_raw_block(hash, None).await?;
+ let block_data = manager.rpc_get_raw_block(hash, None).await;
+ if matches!(block_data, Err(Error::MissingBlock(_))) {
+ warn!(
+ "Could not fetch needed block {:?}, no node returned valid data. Checking that refcount is correct.",
+ hash
+ );
+ manager.rc.recalculate_rc(hash)?;
+ }
+ let block_data = block_data?;
manager.metrics.resync_recv_counter.add(1);