public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Michael Köppl" <m.koeppl@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [PATCH proxmox-backup v5 3/3] fix #7400: proxy: self-heal corrupted job statefiles
Date: Mon, 13 Apr 2026 15:20:00 +0200	[thread overview]
Message-ID: <20260413132000.49889-4-m.koeppl@proxmox.com> (raw)
In-Reply-To: <20260413132000.49889-1-m.koeppl@proxmox.com>

Update update_job_last_run_time to transition JobState::Unknown into
JobState::Created so the corrupted statefile is overwritten. In
addition, update the scheduling loops to actively overwrite corrupted
statefiles and return the time for the next scheduled run of the
affected job.

Signed-off-by: Michael Köppl <m.koeppl@proxmox.com>
---
 src/bin/proxmox-backup-proxy.rs | 6 ++++--
 src/server/jobstate.rs          | 2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/bin/proxmox-backup-proxy.rs b/src/bin/proxmox-backup-proxy.rs
index 2932e4d7b..b18550420 100644
--- a/src/bin/proxmox-backup-proxy.rs
+++ b/src/bin/proxmox-backup-proxy.rs
@@ -33,7 +33,7 @@ use pbs_datastore::DataStore;
 use proxmox_backup::{
     server::{
         auth::check_pbs_auth,
-        jobstate::{self, Job},
+        jobstate::{self, Job, SCHEDULE_FALLBACK_OFFSET},
     },
     traffic_control_cache::{SharedRateLimit, TRAFFIC_CONTROL_CACHE},
 };
@@ -567,6 +567,7 @@ async fn schedule_datastore_garbage_collection() {
             Ok(time) => time,
             Err(err) => {
                 eprintln!("could not get last run time of {worker_type} {store}: {err}");
+                let _ = jobstate::update_job_last_run_time(worker_type, &store);
                 continue;
             }
         };
@@ -1026,7 +1027,8 @@ fn check_schedule(worker_type: &str, event_str: &str, id: &str) -> bool {
         Ok(time) => time,
         Err(err) => {
             eprintln!("could not get last run time of {worker_type} {id}: {err}");
-            return false;
+            let _ = jobstate::update_job_last_run_time(worker_type, id);
+            proxmox_time::epoch_i64() - SCHEDULE_FALLBACK_OFFSET
         }
     };
 
diff --git a/src/server/jobstate.rs b/src/server/jobstate.rs
index 94f3a5e5d..fb96ea1da 100644
--- a/src/server/jobstate.rs
+++ b/src/server/jobstate.rs
@@ -161,7 +161,7 @@ pub fn update_job_last_run_time(jobtype: &str, jobname: &str) -> Result<(), Erro
             state,
             updated: Some(time),
         },
-        JobState::Unknown => bail!("cannot update last run time for unknown job state"),
+        JobState::Unknown => JobState::Created { time },
     };
     job.write_state()
 }
-- 
2.47.3





      parent reply	other threads:[~2026-04-13 13:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-13 13:19 [PATCH proxmox-backup v5 0/3] fix #7400: improve handling of " Michael Köppl
2026-04-13 13:19 ` [PATCH proxmox-backup v5 1/3] api: move statefile loading into compute_schedule_status Michael Köppl
2026-04-13 13:19 ` [PATCH proxmox-backup v5 2/3] fix #7400: api: gracefully handle corrupted job statefiles Michael Köppl
2026-04-13 13:20 ` Michael Köppl [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260413132000.49889-4-m.koeppl@proxmox.com \
    --to=m.koeppl@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal