From 72f0a47563689fe4822c32d6db1acd95289a337b Mon Sep 17 00:00:00 2001 From: chrislu Date: Sun, 10 Aug 2025 18:04:31 -0700 Subject: [PATCH] CRITICAL: Check ALL task states for volume conflicts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix major scheduling bug where only active tasks were checked for conflicts. Changes: - Check PENDING tasks: Prevent scheduling if task is queued for same volume - Check ASSIGNED/ACTIVE tasks: Prevent scheduling if task is running on same volume - Check RECENT tasks: Prevent immediate re-scheduling on same volume after completion This prevents dangerous scenarios like: ❌ Scheduling vacuum while another vacuum is pending on same volume ❌ Scheduling balance while erasure coding is queued for same volume ❌ Immediately re-scheduling failed tasks without cooldown period Critical safety improvement ensuring comprehensive volume-level task isolation. --- weed/admin/topology/internal.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/weed/admin/topology/internal.go b/weed/admin/topology/internal.go index b0ddef9a9..6286f5bca 100644 --- a/weed/admin/topology/internal.go +++ b/weed/admin/topology/internal.go @@ -84,13 +84,28 @@ func (at *ActiveTopology) isDiskAvailableForVolume(disk *activeDisk, taskType Ta return false } - // Check for volume-specific conflicts + // Check for volume-specific conflicts in ALL task states: + // 1. Pending tasks (queued but not yet started) + for _, task := range disk.pendingTasks { + if at.areTasksConflicting(task, taskType, volumeID) { + return false + } + } + + // 2. Assigned/Active tasks (currently running) for _, task := range disk.assignedTasks { if at.areTasksConflicting(task, taskType, volumeID) { return false } } + // 3. Recent tasks (just completed - avoid immediate re-scheduling on same volume) + for _, task := range disk.recentTasks { + if at.areTasksConflicting(task, taskType, volumeID) { + return false + } + } + return true }