From: Samuel Rufinatscha <s.rufinatscha@proxmox.com>
To: Christian Ebner <c.ebner@proxmox.com>, pbs-devel@lists.proxmox.com
Subject: Re: [PATCH proxmox v3 0/3] fix #8341: reduce task list lock contention during old task log cleanup
Date: Thu, 3 Dec 2026 16:12:54 +0100 [thread overview]
Message-ID: <53d57b5f-f374-4b5b-9bb1-1bd371c08a26@proxmox.com> (raw)
In-Reply-To: <20261127161054.401599-1-c.ebner@proxmox.com>
Tested following 3 cases:
1) set the mtime for the log 1 ms before the worker UPID start time ->
cleanup keeps the log while the worker is active
2) held a shared lock on .active.lock so the worker had to wait to
register, then i set the mtime of the logfile to 1 second before archive
cutoff time and ran cleanup -> margin protects the log before the worker
is in the active list
3) paused cleanup during the directory scan and started another worker
-> the new worker could start and finish, so doesn't have to wait for
the scan
Reviewed-by: Samuel Rufinatscha <s.rufinatscha@proxmox.com>
Tested-by: Samuel Rufinatscha <s.rufinatscha@proxmox.com>
On 11/27/26 5:11 PM, Christian Ebner wrote:
> When rotating the task log archive and cleaning up old task logs
> (scheduled daily at midnight in Proxmox Backup Server), an exclusive
> lock was previously held for the entire duration of the cleanup.
>
> On systems with a large number of task logs or slow storage,
> directory traversal during task log cleanup can easily exceed the
> 15 second lock acquisition timeout. Because state updates on any
> worker task requires an exclusive lock on `.active.lock` to update the
> active task list, tasks running concurrently around midnight failed
> with:
> ```
> Unable to acquire lock "/var/log/proxmox-backup/tasks/.active.lock" - Interrupted system call (os error 4)
> ```
>
> Since determining the cutoff timestamp only requires reading the
> oldest entry from the task archive and is not required at all when
> removing the log files for which mtime is older than the cutoff time,
> acquire a shared lock only and drop it after the cutoff time has been
> calculated.
>
> Cutoff calculation now takes also active tasks into account, closing
> previously present race conditions with task log cleanup.
>
> Link to the bugtracker:
> https://bugzilla.proxmox.com/show_bug.cgi?id=8341
>
> Further cleanups are suggested in https://bugzilla.proxmox.com/show_bug.cgi?id=5960
> are not part of this series.
>
> Changes since version 2 (thanks a lot @Samuel for feedback):
> - Fix two more potential races with task creation, this covers
> * Tasks whose log file has been created, but the task not yet registered in
> active task list.
> * mtime < UPID starttime because of system time granularity.
>
> Changes since version 1 (thanks a lot @Robert for feedback):
> - Dropped patch changing error message since the signal interrupting the flock
> call can be unrelated to the timeout.
> - Pull the latest active task gathering out of the loop which checks the
> finished tasks end time. This was needless to be repeated for each finished
> task as the active task list is still locked from being updated anyways.
>
>
> proxmox:
>
> Christian Ebner (3):
> rest-server: use shared instead of exclusive lock for old task cleanup
> fix #8341: rest-server: do not lock task list during old log cleanup
> rest-server: clamp old task log cleanup cutoff to earliest active task
>
> proxmox-rest-server/src/worker_task.rs | 90 ++++++++++++++++++--------
> 1 file changed, 62 insertions(+), 28 deletions(-)
>
>
> Summary over all repositories:
> 1 files changed, 62 insertions(+), 28 deletions(-)
>
prev parent reply other threads:[~2026-12-03 15:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 16:10 [PATCH proxmox v3 0/3] fix #8341: reduce task list lock contention during old task log cleanup Christian Ebner
2026-11-27 16:10 ` [PATCH proxmox v3 1/3] rest-server: use shared instead of exclusive lock for old task cleanup Christian Ebner
2026-11-27 16:10 ` [PATCH proxmox v3 2/3] fix #8341: rest-server: do not lock task list during old log cleanup Christian Ebner
2026-11-27 16:10 ` [PATCH proxmox v3 3/3] rest-server: clamp old task log cleanup cutoff to earliest active task Christian Ebner
2026-12-03 15:12 ` Samuel Rufinatscha [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=53d57b5f-f374-4b5b-9bb1-1bd371c08a26@proxmox.com \
--to=s.rufinatscha@proxmox.com \
--cc=c.ebner@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