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 0/9] pull: avoid lock contention with verify on unchanged snapshots
Date: Thu,  3 Dec 2026 16:04:39 +0100	[thread overview]
Message-ID: <20261203150448.412515-1-c.ebner@proxmox.com> (raw)

Pull jobs re-sync the newest already synced snapshot of each group to
fetch a client log that may not have been available during the last
run. This currently takes an exclusive snapshot lock up front,
although the snapshot is unchanged in the vast majority of cases.

Since commit 7241811f7 ("fix #6990: server: drop verify state on
non-decrypt pull job") synced snapshots no longer inherit the verify
state from the source, so a verify job on the target checks every
newly synced snapshot while holding a shared lock. A concurrent pull
then fails to acquire the exclusive lock and aborts the whole group,
delaying newer snapshots until the next run.

This series first checks existing, non-corrupt snapshots under a
shared lock without touching the target snapshot directory. Only if
target changes are required, the shared lock is released and an
exclusive lock is acquired, after which the snapshot state is
re-evaluated.
Unchanged snapshots without a client log on the source skip the
exclusive lock entirely.

Patches 1-5 are preparatory refactorings of the snapshot pull code
without functional changes (apart from one dropped log line on patch
5). Patches 6-7 add timeout-aware exclusive snapshot locking, which
validates the lock against a concurrent removal and recreation of the
snapshot. Patches 8-9 implement the actual change.

Based on a report in the community forum:
https://forum.proxmox.com/threads/187896/

Changes since v1 (thanks @Jakob for review and testing):
- drop the in-place shared to exclusive lock upgrade since internal
  tooling flagged a race on lock upgrade, since flock() upgrades
  are not atomic and bypass the lock inode validation. Instead,
  release the shared lock and acquire a validated exclusive lock with
  timeout, re-evaluating the snapshot state afterwards.
- add BackupDir::lock_with_timeout() and
  create_locked_backup_dir_with_timeout() for the above, including
  tests for contended, timed out and stale inode cases.
- use a named constant for the 15s lock timeout.
- split out refactorings: start logging (now first), deferred sync
  stats, target manifest loading helper and decoupling the decryption
  key decision from logging, so the shared lock check can reuse it.
- split the client log check into its own patch.

Christian Ebner (9):
  server: pull: refactor snapshot sync start logging
  server: pull: defer sync stats instantiation until needed
  server: pull: load source manifest into memory instead of a temp file
  server: pull: move target manifest loading logic into reusable helper
  server: pull: decouple decryption key gathering from logging
  pbs-datastore: add BackupDir::lock_with_timeout()
  pbs-datastore: add create_locked_backup_dir_with_timeout()
  server: pull: check for unchanged snapshots under a shared lock
  server: pull: skip exclusive lock when source has no client log

 pbs-datastore/src/backup_info.rs | 173 +++++++-
 pbs-datastore/src/datastore.rs   |  37 +-
 src/server/pull.rs               | 673 +++++++++++++++++++------------
 src/server/sync.rs               |  89 ++--
 4 files changed, 676 insertions(+), 296 deletions(-)

-- 
2.47.3





             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 Christian Ebner [this message]
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 ` [PATCH v2 proxmox-backup 9/9] server: pull: skip exclusive lock when source has no client log Christian Ebner

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-1-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