From: Christian Ebner <c.ebner@proxmox.com>
To: Robert Obkircher <r.obkircher@proxmox.com>, pbs-devel@lists.proxmox.com
Subject: Re: [PATCH proxmox 4/4] rest-server: clamp old task log cleanup cutoff to earliest active task
Date: Thu, 19 Nov 2026 12:06:22 +0100 [thread overview]
Message-ID: <8395064a-fd0b-4db4-bb75-9b1cf96fe8b9@proxmox.com> (raw)
In-Reply-To: <a66a6fd6-74c1-4786-91d1-feca8ca74307@proxmox.com>
On 11/19/26 11:55 AM, Robert Obkircher wrote:
>
> On 18.11.26 19:02, Christian Ebner wrote:
>> Determining the cutoff timestamp for old task log cleanup previously
>> only inspected the oldest entry in the task archive, which only tracks
>> finished tasks. Still running tasks are listed exclusively in the
>> active tasks file without an end time.
>>
>> If a long-running task started before the calculated archive cutoff
>> time and has not written any new log lines since then, its log file's
>> mtime is older than the cutoff time and cleanup_old_tasks() would
>> remove the log file while the task is still active.
>>
>> Prevent this by also reading the active task list while holding the
>> shared task list lock during cutoff time gathering and clamping the
>> cutoff timestamp to the earliest active task's start time. Since a
>> task's log file is created after its UPID start time is generated,
>> its mtime is guaranteed to be at or after that timestamp.
>>
>> Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
>> ---
>> proxmox-rest-server/src/worker_task.rs | 15 ++++++++++++---
>> 1 file changed, 12 insertions(+), 3 deletions(-)
>>
>> diff --git a/proxmox-rest-server/src/worker_task.rs b/proxmox-rest-server/src/worker_task.rs
>> index 80889451..f1f27ec2 100644
>> --- a/proxmox-rest-server/src/worker_task.rs
>> +++ b/proxmox-rest-server/src/worker_task.rs
>> @@ -264,7 +264,8 @@ impl WorkerTaskSetup {
>> }
>>
>> /// Identify the oldest finished task entry's timestamp by iterating the task
>> - /// archive and return the calculated cutoff time.
>> + /// archive, clamped to the earliest active task's start time, and return the
>> + /// calculated cutoff time.
>> ///
>> /// Note: acquired a shared lock on [`WorkerTaskSetup::task_lock_fn`].
>> fn oldest_task_cutoff_time(&self, compressed: bool,) -> Result<Option<SystemTime>, Error> {
>> @@ -277,7 +278,15 @@ impl WorkerTaskSetup {
>> for line in reader.lines() {
>> let line = line?;
>> if let Ok((_, _, Some(state))) = parse_worker_status_line(&line) {
>> - let timestamp = state.endtime();
>> + let mut timestamp = state.endtime();
>> +
>> + if let Some(oldest_active) = read_task_file_from_path(&self.active_tasks_fn)?
> Couldn't this be read once outside of the loops?
Yeah, better to gather the latest active right after locking. Will send
a v2 dropping patch 1 and pulling this out of the loop, thanks.
>> + .into_iter()
>> + .map(|info| info.upid.starttime)
>> + .min()
>> + {
>> + timestamp = timestamp.min(oldest_active);
>> + }
>>
>> let cutoff_time = if timestamp > 0 {
>> SystemTime::UNIX_EPOCH.checked_add(Duration::from_secs(timestamp as u64))
>> @@ -385,7 +394,7 @@ pub fn rotate_task_log_archive(
>> }
>>
>> /// removes all task logs that are older than the oldest task entry in the
>> -/// task archive
>> +/// task archive and not currently active
>> pub fn cleanup_old_tasks(compressed: bool) -> Result<(), Error> {
>> let setup = worker_task_setup()?;
>>
prev parent reply other threads:[~2026-11-19 11:06 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 18:02 [PATCH proxmox 0/4] fix #8341: reduce task list lock contention during old task log cleanup Christian Ebner
2026-11-18 18:02 ` [PATCH proxmox 1/4] sys: fs: report lock timeouts as such instead of EINTR Christian Ebner
2026-11-19 10:18 ` Robert Obkircher
2026-11-19 10:53 ` Christian Ebner
2026-11-18 18:02 ` [PATCH proxmox 2/4] rest-server: use shared instead of exclusive lock for old task cleanup Christian Ebner
2026-11-18 18:02 ` [PATCH proxmox 3/4] fix #8341: rest-server: do not lock task list during old log cleanup Christian Ebner
2026-11-18 18:02 ` [PATCH proxmox 4/4] rest-server: clamp old task log cleanup cutoff to earliest active task Christian Ebner
2026-11-19 10:55 ` Robert Obkircher
2026-11-19 11:06 ` Christian Ebner [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=8395064a-fd0b-4db4-bb75-9b1cf96fe8b9@proxmox.com \
--to=c.ebner@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
--cc=r.obkircher@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.