From: "Jakob Klocker" <j.klocker@proxmox.com>
To: "Christian Ebner" <c.ebner@proxmox.com>, <pbs-devel@lists.proxmox.com>
Subject: Re: [PATCH proxmox-backup 4/4] server: pull: check unchanged snapshots under a shared lock
Date: Wed, 02 Dec 2026 10:32:38 +0100 [thread overview]
Message-ID: <DNA55UTP007A.1RJ5FESME66Y3@proxmox.com> (raw)
In-Reply-To: <20261201141401.438577-5-c.ebner@proxmox.com>
On Tue Dec 1, 2026 at 3:14 PM CET, Christian Ebner wrote:
> Each pull re-syncs the newest snapshot of a group already present on
> the target, to pick up a client log that was not yet available during
> the previous run. This took an exclusive snapshot lock up front, even
> though the snapshot is usually unchanged.
>
> Since commit 7241811f7 ("fix #6990: server: drop verify state on
> non-decrypt pull job") sync no longer passes the source's verify state
> on to the target and therefore a verify job on the target checks every
> newly synced snapshot, making lock contention more likely.
> Verification holds a shared lock on the snapshot, so the exclusive
> lock attempt of a concurrent sync fails and aborts the whole group,
> delaying newer snapshots syncs until the next run.
>
> To reduce lock contention, acquire a shared lock first for existing,
> non-corrupt snapshots and upgrade it in place to an exclusive lock via
> BackupLockGuard::try_upgrade() only if the target actually needs
> changes. This avoids performing operations which can be under a shared
> lock to be under an exclusive lock.
>
> Whether the source has a client log or not is checked via the snapshot
> listing, so also snapshots without one can be checked under the shared
> lock alone.
>
> Link: https://forum.proxmox.com/threads/187896/
> Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
> [SNIP]
> +
> + fn upgrade_to_exclusive(&mut self) -> Result<(), Error> {
> + match std::mem::replace(&mut self.0, SnapshotLockState::Released) {
> + SnapshotLockState::Exclusive(guard) => {
> + self.0 = SnapshotLockState::Exclusive(guard);
> + Ok(())
> + }
> + SnapshotLockState::Shared(guard) => {
> + // Avoid immediate failure if a concurrent operation is not that long running
> + let guard = guard.try_upgrade(Some(Duration::from_secs(15)))?;
we could add a constant for the 15s, maybe something like
`SNAPSHOT_LOCK_UPGRADE_TIMEOUT`. The constant could then carry the
comment, so it can be dropped at the call site. Just my preference,
either is fine.
> + self.0 = SnapshotLockState::Exclusive(guard);
> + Ok(())
> + }
> + SnapshotLockState::Released => {
> + bail!("internal error: snapshot lock was already released");
> + }
> + }
> + }
> +}
> +
> [SNIP]
next prev parent reply other threads:[~2026-12-02 9:32 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 14:13 [PATCH proxmox-backup 0/4] server: pull: reduce lock contention on unchanged snapshots Christian Ebner
2026-12-01 14:13 ` [PATCH proxmox-backup 1/4] pbs-config: add helper to try upgrade shared lock to exclusive lock Christian Ebner
2026-12-02 9:27 ` Jakob Klocker
2026-12-01 14:13 ` [PATCH proxmox-backup 2/4] server: pull: load source manifest into memory instead of a temp file Christian Ebner
2026-12-01 14:14 ` [PATCH proxmox-backup 3/4] server: pull: log snapshot sync start in pull_snapshot_from Christian Ebner
2026-12-01 14:14 ` [PATCH proxmox-backup 4/4] server: pull: check unchanged snapshots under a shared lock Christian Ebner
2026-12-02 9:32 ` Jakob Klocker [this message]
2026-12-02 9:41 ` [PATCH proxmox-backup 0/4] server: pull: reduce lock contention on unchanged snapshots Jakob Klocker
2026-12-02 9:54 ` Christian Ebner
2026-12-03 15:07 ` superseded: " 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=DNA55UTP007A.1RJ5FESME66Y3@proxmox.com \
--to=j.klocker@proxmox.com \
--cc=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