From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 40A1B1FF0AF for ; Fri, 23 Oct 2026 14:11:59 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id A12A121610; Fri, 23 Oct 2026 14:11:58 +0200 (CEST) From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= To: pbs-devel@lists.proxmox.com Subject: [PATCH proxmox-backup] snapshot locking: improve error contexts Date: Fri, 23 Oct 2026 14:11:29 +0200 Message-ID: <20261023121152.760779-1-f.gruenbichler@proxmox.com> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1792757513792 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.690 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: 573NFDUSEILCYW3ES3VRID6PVUJJVLOG X-Message-ID-Hash: 573NFDUSEILCYW3ES3VRID6PVUJJVLOG X-MailFrom: f.gruenbichler@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: having the struct-debug representation logged is rather noisy, the relative path contains all the relevant information. Signed-off-by: Fabian Grünbichler --- Notes: this is still often redundant, since context higher up might contain the API-type BackupDir, and the error itself might contain multiple copies of the lock path, but it's still an improvement.. pbs-datastore/src/datastore.rs | 9 ++++++--- src/api2/reader/mod.rs | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs index d6dcce77f..665333f52 100644 --- a/pbs-datastore/src/datastore.rs +++ b/pbs-datastore/src/datastore.rs @@ -1870,14 +1870,14 @@ impl DataStore { match std::fs::create_dir(backup_dir.full_path()) { Ok(_) => { let guard = backup_dir.lock().with_context(|| { - format!("while creating new locked snapshot '{backup_dir:?}'") + format!("while creating new locked snapshot {relative_path:?}") })?; Ok((relative_path, true, guard)) } Err(ref e) if e.kind() == io::ErrorKind::AlreadyExists => { let guard = backup_dir .lock() - .with_context(|| format!("while creating locked snapshot '{backup_dir:?}'"))?; + .with_context(|| format!("while creating locked snapshot {relative_path:?}"))?; Ok((relative_path, false, guard)) } Err(e) => Err(e.into()), @@ -2838,7 +2838,10 @@ impl DataStore { } let _guard = backup_dir.lock().with_context(|| { - format!("while updating the protection status of snapshot '{backup_dir:?}'") + format!( + "while updating the protection status of snapshot {:?}", + backup_dir.relative_path() + ) })?; let protected_path = backup_dir.protected_file(); diff --git a/src/api2/reader/mod.rs b/src/api2/reader/mod.rs index 4321d2286..29c00e74c 100644 --- a/src/api2/reader/mod.rs +++ b/src/api2/reader/mod.rs @@ -131,12 +131,12 @@ fn upgrade_to_backup_reader_protocol( } if !backup_dir.full_path().exists() { - bail!("snapshot {} does not exist.", backup_dir.dir()); + bail!("snapshot {:?} does not exist.", backup_dir.relative_path()); } let _guard = backup_dir .lock_shared() - .with_context(|| format!("while reading snapshot '{backup_dir:?}'"))?; + .with_context(|| format!("while reading snapshot {:?}", backup_dir.relative_path()))?; let path = datastore.base_path(); -- 2.47.3