From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id D10D61FF0E3 for ; Wed, 02 Dec 2026 10:32:43 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 881E1213A2; Wed, 02 Dec 2026 10:32:43 +0100 (CET) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Wed, 02 Dec 2026 10:32:38 +0100 Message-Id: Subject: Re: [PATCH proxmox-backup 4/4] server: pull: check unchanged snapshots under a shared lock From: "Jakob Klocker" To: "Christian Ebner" , X-Mailer: aerc 0.20.0 References: <20261201141401.438577-1-c.ebner@proxmox.com> <20261201141401.438577-5-c.ebner@proxmox.com> In-Reply-To: <20261201141401.438577-5-c.ebner@proxmox.com> X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1796203958195 X-SPAM-LEVEL: Spam detection results: 0 AWL 1.048 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: 34VJCFUGYMSQSBWA6S6VFV7KDBZU365I X-Message-ID-Hash: 34VJCFUGYMSQSBWA6S6VFV7KDBZU365I X-MailFrom: j.klocker@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: 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 > [SNIP] > + > + fn upgrade_to_exclusive(&mut self) -> Result<(), Error> { > + match std::mem::replace(&mut self.0, SnapshotLockState::Released= ) { > + SnapshotLockState::Exclusive(guard) =3D> { > + self.0 =3D SnapshotLockState::Exclusive(guard); > + Ok(()) > + } > + SnapshotLockState::Shared(guard) =3D> { > + // Avoid immediate failure if a concurrent operation is = not that long running > + let guard =3D 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 =3D SnapshotLockState::Exclusive(guard); > + Ok(()) > + } > + SnapshotLockState::Released =3D> { > + bail!("internal error: snapshot lock was already release= d"); > + } > + } > + } > +} > + > [SNIP]