public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Christian Ebner <c.ebner@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [PATCH v2 proxmox-backup 9/9] server: pull: skip exclusive lock when source has no client log
Date: Thu,  3 Dec 2026 16:04:48 +0100	[thread overview]
Message-ID: <20261203150448.412515-10-c.ebner@proxmox.com> (raw)
In-Reply-To: <20261203150448.412515-1-c.ebner@proxmox.com>

Check from the source snapshot listing whether a client log exists on
the source and pass that into pull_snapshot_from().

Unchanged snapshots without a client log on the source no longer need
to acquire an exclusive lock just to find out there is actually no
client log available on the source.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
---
 src/server/pull.rs | 31 ++++++++++++++++++++-----------
 1 file changed, 20 insertions(+), 11 deletions(-)

diff --git a/src/server/pull.rs b/src/server/pull.rs
index ae780d0db..f36ae305b 100644
--- a/src/server/pull.rs
+++ b/src/server/pull.rs
@@ -800,6 +800,7 @@ async fn check_snapshot_under_shared_lock<'a>(
     reader: Arc<dyn SyncSourceReader + 'a>,
     snapshot: &'a pbs_datastore::BackupDir,
     _shared_lock: BackupLockGuard,
+    source_has_client_log: bool,
     log_sender: Arc<LogLineSender>,
 ) -> Result<Option<Vec<u8>>, Error> {
     let prefix = snapshot.backup_time_string().to_owned();
@@ -860,7 +861,7 @@ async fn check_snapshot_under_shared_lock<'a>(
         )
     };
 
-    if unchanged && client_log_name.exists() {
+    if unchanged && (client_log_name.exists() || !source_has_client_log) {
         log_sender
             .log(Level::INFO, format!("{prefix}: no data changes"))
             .await?;
@@ -1219,6 +1220,7 @@ async fn pull_snapshot_from<'a>(
     snapshot: &'a pbs_datastore::BackupDir,
     encountered_chunks: Arc<Mutex<EncounteredChunks>>,
     corrupt: bool,
+    source_has_client_log: bool,
     log_sender: Arc<LogLineSender>,
 ) -> Result<SyncStats, Error> {
     let prefix = snapshot.backup_time_string().to_string();
@@ -1241,6 +1243,7 @@ async fn pull_snapshot_from<'a>(
                     Arc::clone(&reader),
                     snapshot,
                     shared_lock,
+                    source_has_client_log,
                     Arc::clone(&log_sender),
                 )
                 .await?
@@ -1368,8 +1371,9 @@ async fn pull_group(
         .unwrap_or(i64::MIN);
 
     // Filter remote BackupDirs to include in pull
-    // Also stores if the snapshot is corrupt (verification job failed)
-    let list: Vec<(BackupDir, bool)> = raw_list
+    // Also stores if the snapshot is corrupt (verification job failed) and if the source has a
+    // client log
+    let list: Vec<(BackupDir, bool, bool)> = raw_list
         .into_iter()
         .filter_map(|item| {
             if exclude_not_verified_or_encrypted(&item, params.verified_only, params.encrypted_only)
@@ -1377,6 +1381,10 @@ async fn pull_group(
                 return None;
             }
 
+            let has_client_log = item
+                .files
+                .iter()
+                .any(|file| file.filename == CLIENT_LOG_BLOB_NAME.as_ref());
             let dir = item.backup;
             source_snapshots.insert(dir.time);
             // If resync_corrupt is set, check if the corresponding local snapshot failed to
@@ -1391,7 +1399,7 @@ async fn pull_group(
                         match local_dir.verify_state() {
                             Ok(Some(state)) => {
                                 if state == VerifyState::Failed {
-                                    return Some((dir, true));
+                                    return Some((dir, true, has_client_log));
                                 }
                             }
                             Ok(None) => {
@@ -1401,13 +1409,13 @@ async fn pull_group(
                             Err(_) => {
                                 // There was an error loading the manifest, probably better if we
                                 // resync.
-                                return Some((dir, true));
+                                return Some((dir, true, has_client_log));
                             }
                         }
                     }
                 }
             }
-            Some((dir, false))
+            Some((dir, false, has_client_log))
         })
         .collect();
 
@@ -1417,12 +1425,12 @@ async fn pull_group(
         .map(|count| total_amount.saturating_sub(count))
         .unwrap_or_default();
 
-    let list: Vec<(BackupDir, bool)> = list
+    let list: Vec<(BackupDir, bool, bool)> = list
         .into_iter()
         .enumerate()
-        .filter_map(|(pos, (dir, needs_resync))| {
+        .filter_map(|(pos, (dir, needs_resync, has_client_log))| {
             if params.resync_corrupt && needs_resync {
-                return Some((dir, needs_resync));
+                return Some((dir, needs_resync, has_client_log));
             }
             // Note: the snapshot represented by `last_sync_time` might be missing its backup log
             // or post-backup verification state if those were not yet available during the last
@@ -1435,7 +1443,7 @@ async fn pull_group(
                 transfer_last_skip_info.update(dir.time);
                 return None;
             }
-            Some((dir, needs_resync))
+            Some((dir, needs_resync, has_client_log))
         })
         .collect();
 
@@ -1530,7 +1538,7 @@ async fn pull_group(
 
     let mut sync_stats = SyncStats::default();
 
-    for (pos, (from_snapshot, corrupt)) in list.into_iter().enumerate() {
+    for (pos, (from_snapshot, corrupt, source_has_client_log)) in list.into_iter().enumerate() {
         let to_snapshot = params
             .target
             .store
@@ -1546,6 +1554,7 @@ async fn pull_group(
             &to_snapshot,
             encountered_chunks.clone(),
             corrupt,
+            source_has_client_log,
             Arc::clone(&log_sender),
         )
         .await;
-- 
2.47.3





      parent reply	other threads:[~2026-12-03 15:05 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 15:04 [PATCH v2 proxmox-backup 0/9] pull: avoid lock contention with verify on unchanged snapshots Christian Ebner
2026-12-03 15:04 ` [PATCH v2 proxmox-backup 1/9] server: pull: refactor snapshot sync start logging Christian Ebner
2026-12-03 15:04 ` [PATCH v2 proxmox-backup 2/9] server: pull: defer sync stats instantiation until needed Christian Ebner
2026-12-03 15:04 ` [PATCH v2 proxmox-backup 3/9] server: pull: load source manifest into memory instead of a temp file Christian Ebner
2026-12-03 15:04 ` [PATCH v2 proxmox-backup 4/9] server: pull: move target manifest loading logic into reusable helper Christian Ebner
2026-12-03 15:04 ` [PATCH v2 proxmox-backup 5/9] server: pull: decouple decryption key gathering from logging Christian Ebner
2026-12-03 15:04 ` [PATCH v2 proxmox-backup 6/9] pbs-datastore: add BackupDir::lock_with_timeout() Christian Ebner
2026-12-03 15:04 ` [PATCH v2 proxmox-backup 7/9] pbs-datastore: add create_locked_backup_dir_with_timeout() Christian Ebner
2026-12-03 15:04 ` [PATCH v2 proxmox-backup 8/9] server: pull: check for unchanged snapshots under a shared lock Christian Ebner
2026-12-03 15:04 ` 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=20261203150448.412515-10-c.ebner@proxmox.com \
    --to=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
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal