diff options
author | Alex Auvolat <alex@adnab.me> | 2022-12-14 15:25:29 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2022-12-14 15:25:29 +0100 |
commit | dfc131850a09e7ceacfa98315adbef156e07e9ca (patch) | |
tree | b9684958e211e0dd0389c12a166c9d1af5e8b5f9 /src/table | |
parent | d4af27f920ce48a60f2073e98b17bdf963241686 (diff) | |
download | garage-dfc131850a09e7ceacfa98315adbef156e07e9ca.tar.gz garage-dfc131850a09e7ceacfa98315adbef156e07e9ca.zip |
Simplified and more aggressive worker exit logic
Diffstat (limited to 'src/table')
-rw-r--r-- | src/table/gc.rs | 5 | ||||
-rw-r--r-- | src/table/merkle.rs | 5 | ||||
-rw-r--r-- | src/table/queue.rs | 5 | ||||
-rw-r--r-- | src/table/sync.rs | 5 |
4 files changed, 4 insertions, 16 deletions
diff --git a/src/table/gc.rs b/src/table/gc.rs index 1fc16364..90594fba 100644 --- a/src/table/gc.rs +++ b/src/table/gc.rs @@ -348,10 +348,7 @@ where } } - async fn wait_for_work(&mut self, must_exit: &watch::Receiver<bool>) -> WorkerState { - if *must_exit.borrow() { - return WorkerState::Done; - } + async fn wait_for_work(&mut self) -> WorkerState { tokio::time::sleep(self.wait_delay).await; WorkerState::Busy } diff --git a/src/table/merkle.rs b/src/table/merkle.rs index 0fe7d2cb..736354fa 100644 --- a/src/table/merkle.rs +++ b/src/table/merkle.rs @@ -340,10 +340,7 @@ where .unwrap() } - async fn wait_for_work(&mut self, must_exit: &watch::Receiver<bool>) -> WorkerState { - if *must_exit.borrow() { - return WorkerState::Done; - } + async fn wait_for_work(&mut self) -> WorkerState { select! { _ = tokio::time::sleep(Duration::from_secs(60)) => (), _ = self.0.data.merkle_todo_notify.notified() => (), diff --git a/src/table/queue.rs b/src/table/queue.rs index 3671ea7d..860f20d3 100644 --- a/src/table/queue.rs +++ b/src/table/queue.rs @@ -71,10 +71,7 @@ where Ok(WorkerState::Busy) } - async fn wait_for_work(&mut self, must_exit: &watch::Receiver<bool>) -> WorkerState { - if *must_exit.borrow() { - return WorkerState::Done; - } + async fn wait_for_work(&mut self) -> WorkerState { select! { _ = tokio::time::sleep(Duration::from_secs(600)) => (), _ = self.0.data.insert_queue_notify.notified() => (), diff --git a/src/table/sync.rs b/src/table/sync.rs index 1e7618ca..d6d272ab 100644 --- a/src/table/sync.rs +++ b/src/table/sync.rs @@ -593,10 +593,7 @@ impl<F: TableSchema + 'static, R: TableReplication + 'static> Worker for SyncWor } } - async fn wait_for_work(&mut self, must_exit: &watch::Receiver<bool>) -> WorkerState { - if *must_exit.borrow() { - return WorkerState::Done; - } + async fn wait_for_work(&mut self) -> WorkerState { select! { s = self.add_full_sync_rx.recv() => { if let Some(()) = s { |