From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id A15AD1FF0C0 for ; Wed, 18 Nov 2026 19:02:50 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id C65AB21735; Wed, 18 Nov 2026 19:02:49 +0100 (CET) From: Christian Ebner To: pbs-devel@lists.proxmox.com Subject: [PATCH proxmox 2/4] rest-server: use shared instead of exclusive lock for old task cleanup Date: Wed, 18 Nov 2026 19:02:26 +0100 Message-ID: <20261118180228.341628-3-c.ebner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261118180228.341628-1-c.ebner@proxmox.com> References: <20261118180228.341628-1-c.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1795024965342 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.363 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: B6THGR2YB3VZDTAJZG5U4P5CHAFGQYEF X-Message-ID-Hash: B6THGR2YB3VZDTAJZG5U4P5CHAFGQYEF X-MailFrom: c.ebner@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Backup Server development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Cleanup of old task logs happens by identifying the oldest task entry in the task archive. To protect against races by concurrent task archive file updates, this is protected by a file lock. Currently an exclusive lock is acquired, the oldest task cleanup however only reads, never modifies the files so a shared lock is sufficient. Since active worker updates and task log archive rotation still acquire an exclusive lock, they cannot interfere. Parts of the iteration via the task list info iterator might now happen concurrently, but these cannot interfere since both read the same task from the archive, which does not include old task logs to be cleaned up and active worker updates during iteration still require the exclusive lock. Signed-off-by: Christian Ebner --- proxmox-rest-server/src/worker_task.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proxmox-rest-server/src/worker_task.rs b/proxmox-rest-server/src/worker_task.rs index dfd0def6..d43c42ba 100644 --- a/proxmox-rest-server/src/worker_task.rs +++ b/proxmox-rest-server/src/worker_task.rs @@ -358,7 +358,7 @@ pub fn rotate_task_log_archive( pub fn cleanup_old_tasks(compressed: bool) -> Result<(), Error> { let setup = worker_task_setup()?; - let _lock = setup.lock_task_list_files(true)?; + let _lock = setup.lock_task_list_files(false)?; let logrotate = LogRotate::new(&setup.task_archive_fn, compressed, None, None)?; -- 2.47.3