mirror of
https://git.deuxfleurs.fr/Deuxfleurs/garage.git
synced 2024-11-14 04:01:25 +00:00
Spawn a single resync worker
This commit is contained in:
parent
dc5ec4ecf9
commit
f7e6f4616f
1 changed files with 7 additions and 11 deletions
|
@ -38,7 +38,6 @@ use crate::garage::Garage;
|
||||||
/// Size under which data will be stored inlined in database instead of as files
|
/// Size under which data will be stored inlined in database instead of as files
|
||||||
pub const INLINE_THRESHOLD: usize = 3072;
|
pub const INLINE_THRESHOLD: usize = 3072;
|
||||||
|
|
||||||
pub const BACKGROUND_WORKERS: u64 = 1;
|
|
||||||
pub const BACKGROUND_TRANQUILITY: u32 = 2;
|
pub const BACKGROUND_TRANQUILITY: u32 = 2;
|
||||||
|
|
||||||
// Timeout for RPCs that read and write blocks to remote nodes
|
// Timeout for RPCs that read and write blocks to remote nodes
|
||||||
|
@ -512,17 +511,14 @@ impl BlockManager {
|
||||||
// ---- Resync loop ----
|
// ---- Resync loop ----
|
||||||
|
|
||||||
pub fn spawn_background_worker(self: Arc<Self>) {
|
pub fn spawn_background_worker(self: Arc<Self>) {
|
||||||
// Launch n simultaneous workers for background resync loop preprocessing
|
// Launch a background workers for background resync loop processing
|
||||||
for i in 0..BACKGROUND_WORKERS {
|
let background = self.system.background.clone();
|
||||||
let bm2 = self.clone();
|
tokio::spawn(async move {
|
||||||
let background = self.system.background.clone();
|
tokio::time::sleep(Duration::from_secs(10)).await;
|
||||||
tokio::spawn(async move {
|
background.spawn_worker("block resync worker".into(), move |must_exit| {
|
||||||
tokio::time::sleep(Duration::from_secs(10 * (i + 1))).await;
|
self.resync_loop(must_exit)
|
||||||
background.spawn_worker(format!("block resync worker {}", i), move |must_exit| {
|
|
||||||
bm2.resync_loop(must_exit)
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn put_to_resync(&self, hash: &Hash, delay: Duration) -> Result<(), Error> {
|
fn put_to_resync(&self, hash: &Hash, delay: Duration) -> Result<(), Error> {
|
||||||
|
|
Loading…
Reference in a new issue