public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Christian Ebner <c.ebner@proxmox.com>
To: Jakob Klocker <j.klocker@proxmox.com>, pbs-devel@lists.proxmox.com
Subject: Re: [PATCH proxmox-backup 0/4] server: pull: reduce lock contention on unchanged snapshots
Date: Wed, 2 Dec 2026 10:54:13 +0100	[thread overview]
Message-ID: <974f7df5-f488-4cd4-877a-00888d16972d@proxmox.com> (raw)
In-Reply-To: <DNA5C9NPP5PY.1PGVL94I4KZJF@proxmox.com>

On 12/2/26 10:41 AM, Jakob Klocker wrote:
> On Tue Dec 1, 2026 at 3:13 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. Currently this acquires 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"), pull jobs no longer inherit the source's
>> verify state, so verify jobs on the target check every newly synced
>> snapshot while holding a shared lock. Concurrent pull jobs then fail
>> to acquire the exclusive lock and abort the whole group, delaying
>> newer snapshots until the next run.
>>
>> This series checks existing, non-corrupt snapshots under a shared
>> lock first and upgrades the lock in place to exclusive only when
>> target changes are actually required:
>>
>> - Patch 1 adds a BackupLockGuard::try_upgrade() helper for upgrading
>>    a shared lock to exclusive in place.
>> - Patch 2 implements SyncSourceReader::load_file_bytes() and loads
>>    the source manifest into memory only during pull instead of writing
>>    the temporary index.json.tmp into the target snapshot directory.
>> - Patch 3 refactors the initial sync/re-sync logging
>> - Patch 4 finally adapts snapshot checks to start under a shared lock
>>    and only upgrade to an exclusive lock when modifications to the
>>    snapshot are needed.
>>
>> Based on a report in the community forum:
>> https://forum.proxmox.com/threads/187896/
>>
>> Christian Ebner (4):
>>    pbs-config: add helper to try upgrade shared lock to exclusive lock
>>    server: pull: load source manifest into memory instead of a temp file
>>    server: pull: log snapshot sync start in pull_snapshot_from
>>    server: pull: check unchanged snapshots under a shared lock
>>
>>   pbs-config/Cargo.toml |   3 +
>>   pbs-config/src/lib.rs |  80 +++++++++++++++++
>>   src/server/pull.rs    | 201 +++++++++++++++++++++++++++++-------------
>>   src/server/sync.rs    |  89 +++++++++++++------
>>   4 files changed, 286 insertions(+), 87 deletions(-)
>>
> 
> Thanks for picking this up so quickly after the forum report!
> I've left some minor comments on patch 1 & 4.

Thanks, will address these in a v2.

> I've run following tests:
> Reproduced the reported bug without the patches applied by holding a
> shared lock on the newest already synced snapshot of a group on the
> target datastore, simulating a verify job, and running a local pull
> sync job. The group failed with "os error 11" and the newer source
> snapshot was not synced.
> 
> With the patches applied, the same setup syncs without errors: with
> the shared lock held on the newest snapshot of the group on the target
> (verified via lslocks), the sync reports that snapshot as "no data
> changes" and syncs the newer source snapshot. The task finishes OK.
> 
> Also tested the lock upgrade path:
> - lock held > 15s: the upgrade times out after 15s and the group fails
>    (expected)
> - lock released after ~7s: the sync waits, upgrades the lock, fetches
>    the client log and finishes OK
> 
> In the timeout case, the resulting error reads:
> 
>    sync group vm/103 failed - 2026-12-02T08:49:58Z: unable to upgrade
>    lock to exclusive - Interrupted system call (os error 4)
> 
> The EINTR is the timeout, but that's not obvious to users. Maybe map
> it to something like "snapshot in use by another task (e.g. verify),
> timed out after 15s waiting for exclusive lock"?

Thanks a lot for review and testing, note that the timeout might be 
interrupted by another signal though (as noted by Robert in context of a 
similar fix on another patch [0]) so I would rather keep it as is since 
then it might not swallow this information.

[0] 
https://lore.proxmox.com/pbs-devel/553529c1-6a4f-4ec0-9ac5-bab9a22562aa@proxmox.com/





  reply	other threads:[~2026-12-02  9:54 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
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 [this message]
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=974f7df5-f488-4cd4-877a-00888d16972d@proxmox.com \
    --to=c.ebner@proxmox.com \
    --cc=j.klocker@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