Uh oh!
There was an error while loading. Please reload this page.
Allow parallel execution of NAS backup and delete commands - #12847
Allow parallel execution of NAS backup and delete commands#12847jmsperu wants to merge 7 commits into
Conversation
Change executeInSequence() to return false for TakeBackupCommand and DeleteBackupCommand, allowing the KVM agent to process multiple backup/delete operations concurrently via its worker thread pool. Previously, all backup commands were serialized — a large VM backup (e.g. 100+ GB taking 2+ hours) would block all other backup and delete operations on the same host. Since each backup mounts its own temporary NFS directory and operates on independent VM disks, there is no shared state requiring serialization. Restore and PrepareForBackupRestoration commands remain sequential as they modify VM state that should not be concurrent. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@## 4.20 #12847 +/- ##
============================================
+ Coverage 16.24% 16.26% +0.01% - Complexity 13411 13435 +24
============================================
Files 5664 5667 +3 Lines 500463 500737 +274 Branches 60779 60804 +25 ============================================
+ Hits 81308 81451 +143 - Misses 410059 410178 +119 - Partials 9096 9108 +12
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR changes CloudStack backup agent command scheduling by making the NAS backup take and delete commands eligible for parallel execution on the agent (instead of being forced through the single-threaded “in-sequence” queue).
Changes:
- Make
TakeBackupCommand.executeInSequence()returnfalse. - Make
DeleteBackupCommand.executeInSequence()returnfalse.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| core/src/main/java/org/apache/cloudstack/backup/TakeBackupCommand.java | Marks backup creation command as non-sequential (parallelizable) on the agent. |
| core/src/main/java/org/apache/cloudstack/backup/DeleteBackupCommand.java | Marks backup deletion command as non-sequential (parallelizable) on the agent. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
winterhazel
commented
May 13, 2026
@JoaoJandre could you have a look at whether this change would affect KBOSS? |
JoaoJandre
commented
May 14, 2026
@winterhazel KBOSS uses its own commands to send messages to the agent, thus this does not affect it. |
winterhazel
commented
May 21, 2026
@jmsperu could you have a look at @abh1sar's comment at #12847 (comment)? |
jmsperu
commented
May 22, 2026
Thanks for the ping @winterhazel — and @abh1sar's point at #12847 (comment) is well taken. DeleteBackup needs sequential execution because parallel deletes against the same NAS path can race on the cleanup of the chain (we've also seen the rm -rf vs mount/unmount interleave produce stuck mounts). Will restrict the parallelization to TakeBackup only in the next push — DeleteBackup keeps its current sequential behaviour. Thanks @JoaoJandre for the KBOSS confirmation too. |
Revert DeleteBackupCommand to executeInSequence()=true per @abh1sar's review. Backup creation is safe to parallelize across VMs because each VM writes to its own NAS path. Backup deletion is not safe to parallelize the same way: incremental chains share parent qcow2 files on the NAS, and concurrent deletions of sibling or descendant nodes can race on the underlying file references and the chain metadata. Until that's modeled explicitly, keep DeleteBackup serialized. TakeBackup parallelization stands.
jmsperu
commented
May 22, 2026
winterhazel
commented
May 22, 2026
@blueorangutan package |
blueorangutan
commented
May 22, 2026
@winterhazel a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
jmsperu
commented
May 22, 2026
Notes on the current red checks — all three appear unrelated to this change (which is a single
Happy to rebase to retrigger if a reviewer prefers a fresh CI run, but the change itself is unaffected by these matrices. Other 14 checks green, 8 still running. |
blueorangutan
commented
May 22, 2026
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 17997 |
DaanHoogland
commented
May 26, 2026
@blueorangutan test |
blueorangutan
commented
May 26, 2026
@DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
blueorangutan
commented
May 27, 2026
[SF] Trillian test result (tid-16181)
|
Per Daan's review on PR apache#12847, document inline why we return false from executeInSequence — the same reasoning previously only given in the PR thread. The comment explains the design intent (parallel dispatch with DeleteBackupCommand) and the safety case (per-VM on-NAS paths + per-script NFS mount lifecycle).
sbrueseke
commented
Jul 20, 2026
Does it make sense to add new global settings parameter so be able to edit this? |
Uh oh!
There was an error while loading. Please reload this page.
…essential reasoning
…led setting (Zone, default true) to toggle parallel take-backup execution
jmsperu
commented
Jul 28, 2026
@sbrueseke good suggestion — added a global setting |
…ng the executeInSequence toggle
DaanHoogland
commented
Aug 4, 2026
@blueorangutan package |
DaanHoogland
commented
Aug 4, 2026
@sbrueseke are you willing to test this? |
Summary
executeInSequence()fromtruetofalseinTakeBackupCommandandDeleteBackupCommandRestoreBackupCommandandPrepareForBackupRestorationCommandremain sequential (they modify VM state)Motivation
Currently all backup commands are serialized on the agent — a large VM backup (e.g. 100+ GB taking 2+ hours) blocks all other backup and delete operations on the same host. This is the root cause of backup schedule delays and timeouts in environments with many VMs per host.
Each backup operation:
mktemp -d -t csbackup.XXXXX)There is no technical reason to serialize them. The agent already has a thread pool (
requestHandler) that can execute multiple commands concurrently — this change simply allows backup commands to use it.Impact
Test plan
virsh domjobinfoon multiple VMs)-bbandwidth throttle if NFS saturates