aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-06-03 12:56:35 +0200
committerAlex Auvolat <alex@adnab.me>2022-06-03 12:56:35 +0200
commit9bb58638f044722b58c7a88711fa474152d716b6 (patch)
treeb630fef6f8e1eba1f4f07ce24c1ccb3736d52aad
parent295bc2741f427106a00c9a965d3ae50bcb36107d (diff)
downloadgarage-9bb58638f044722b58c7a88711fa474152d716b6.tar.gz
garage-9bb58638f044722b58c7a88711fa474152d716b6.zip
Fix block repair to not deadlock with sqlite
-rw-r--r--src/block/manager.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/block/manager.rs b/src/block/manager.rs
index 73dd453f..decf33cc 100644
--- a/src/block/manager.rs
+++ b/src/block/manager.rs
@@ -218,9 +218,17 @@ impl BlockManager {
/// to fix any mismatch between the two.
pub async fn repair_data_store(&self, must_exit: &watch::Receiver<bool>) -> Result<(), Error> {
// 1. Repair blocks from RC table.
+ // TODO don't do this like this
+ let mut hashes = vec![];
for (i, entry) in self.rc.rc.iter()?.enumerate() {
let (hash, _) = entry?;
let hash = Hash::try_from(&hash[..]).unwrap();
+ hashes.push(hash);
+ if i & 0xFF == 0 && *must_exit.borrow() {
+ return Ok(());
+ }
+ }
+ for (i, hash) in hashes.into_iter().enumerate() {
self.put_to_resync(&hash, Duration::from_secs(0))?;
if i & 0xFF == 0 && *must_exit.borrow() {
return Ok(());