diff options
author | Alex Auvolat <alex@adnab.me> | 2020-04-17 18:51:29 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2020-04-17 18:51:29 +0200 |
commit | db1c4222cefa99c6a4453da13bdb4f206b4b05a5 (patch) | |
tree | 5a3fabb3626ed15152fd500a1454c02a3c1b382e /src/block.rs | |
parent | 4bacaaf53f14ab9340795a5aa98124816d2dab9b (diff) | |
download | garage-db1c4222cefa99c6a4453da13bdb4f206b4b05a5.tar.gz garage-db1c4222cefa99c6a4453da13bdb4f206b4b05a5.zip |
Don't send items...
...if syncer doesn't need them because he's going to delete the partition anyway.
Also, fix block resync queue
Diffstat (limited to 'src/block.rs')
-rw-r--r-- | src/block.rs | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/block.rs b/src/block.rs index 4be8df37..e209dab6 100644 --- a/src/block.rs +++ b/src/block.rs @@ -2,11 +2,11 @@ use std::path::PathBuf; use std::sync::Arc; use std::time::Duration; +use arc_swap::ArcSwapOption; use futures::stream::*; use tokio::fs; use tokio::prelude::*; use tokio::sync::{watch, Mutex}; -use arc_swap::ArcSwapOption; use crate::data; use crate::data::*; @@ -48,8 +48,7 @@ impl BlockManager { pub async fn spawn_background_worker(self: Arc<Self>) { let bm2 = self.clone(); - self - .system + self.system .background .spawn_worker(move |must_exit| bm2.resync_loop(must_exit)) .await; @@ -139,7 +138,11 @@ impl BlockManager { while !*must_exit.borrow() { if let Some((time_bytes, hash_bytes)) = self.resync_queue.get_gt(&[])? { let time_msec = u64_from_bytes(&time_bytes[0..8]); - eprintln!("First in resync queue: {} (now = {})", time_msec, now_msec()); + eprintln!( + "First in resync queue: {} (now = {})", + time_msec, + now_msec() + ); if now_msec() >= time_msec { let mut hash = [0u8; 32]; hash.copy_from_slice(hash_bytes.as_ref()); @@ -147,7 +150,7 @@ impl BlockManager { match self.resync_iter(&hash).await { Ok(_) => { - self.resync_queue.remove(&hash_bytes)?; + self.resync_queue.remove(&time_bytes)?; } Err(e) => { eprintln!( @@ -175,11 +178,17 @@ impl BlockManager { .map(|x| u64_from_bytes(x.as_ref()) > 0) .unwrap_or(false); - eprintln!("Resync block {:?}: exists {}, needed {}", hash, exists, needed); + eprintln!( + "Resync block {:?}: exists {}, needed {}", + hash, exists, needed + ); if exists && !needed { let garage = self.garage.load_full().unwrap(); - let active_refs = garage.block_ref_table.get_range(&hash, &[0u8; 32].into(), Some(()), 1).await?; + let active_refs = garage + .block_ref_table + .get_range(&hash, &[0u8; 32].into(), Some(()), 1) + .await?; let needed_by_others = !active_refs.is_empty(); if needed_by_others { // TODO check they have it and send it if not |