public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [PATCH v2 proxmox-backup 0/9] pull: avoid lock contention with verify on unchanged snapshots
@ 2026-12-03 15:04 Christian Ebner
  2026-12-03 15:04 ` [PATCH v2 proxmox-backup 1/9] server: pull: refactor snapshot sync start logging Christian Ebner
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: Christian Ebner @ 2026-12-03 15:04 UTC (permalink / raw)
  To: pbs-devel

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





^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2026-12-03 15:05 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH v2 proxmox-backup 9/9] server: pull: skip exclusive lock when source has no client log Christian Ebner

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