[pbs-devel] [PATCH proxmox-backup 6/8] syncjob: use JobState for determining when to run next scheduled sync
Dominik Csapak
d.csapak at proxmox.com
Fri Jul 31 14:43:28 CEST 2020
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
src/bin/proxmox-backup-proxy.rs | 30 +++++++++++++++++++++---------
1 file changed, 21 insertions(+), 9 deletions(-)
diff --git a/src/bin/proxmox-backup-proxy.rs b/src/bin/proxmox-backup-proxy.rs
index eea322fc..2103dfef 100644
--- a/src/bin/proxmox-backup-proxy.rs
+++ b/src/bin/proxmox-backup-proxy.rs
@@ -509,20 +509,32 @@ async fn schedule_datastore_sync_jobs() {
let worker_type = "syncjob";
- let last = match lookup_last_worker(worker_type, &job_id) {
- Ok(Some(upid)) => {
- if proxmox_backup::server::worker_is_active_local(&upid) {
- continue;
- }
- upid.starttime
- },
- Ok(None) => 0,
+ let laststate = match JobState::try_read_or_create(worker_type, &job_id) {
+ Ok(state) => state,
Err(err) => {
- eprintln!("lookup_last_job_start failed: {}", err);
+ eprintln!("could not load last state: {}", err);
continue;
}
};
+ match laststate.upid {
+ Some(upid) => {
+ let upid: crate::server::UPID = match upid.parse() {
+ Ok(upid) => upid,
+ Err(err) => {
+ eprintln!("could not parse upid from state: {}", err);
+ continue;
+ }
+ };
+ if proxmox_backup::server::worker_is_active_local(&upid) {
+ continue;
+ }
+ }
+ None => {},
+ }
+
+ let last = laststate.starttime as i64;
+
let next = match compute_next_event(&event, last, false) {
Ok(next) => next,
Err(err) => {
--
2.20.1
More information about the pbs-devel
mailing list