From d41bbe5d2e42952142c2b78afd9eb64df8ff0799 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 5 Mar 2026 20:38:05 +0000 Subject: [PATCH] Bug 41959: Handle edge case With a single hold at least the RETRY loop was never activated after an initial pass with 1 hold We try the hold - it cannot be filled - is removed from the requests array The number of tasks is now 0, less than agents (1) and we don't enter remaining loop For this case we also need to always splice 1 from remaining, or it doesn't shrink --- C4/HoldsQueue.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/C4/HoldsQueue.pm b/C4/HoldsQueue.pm index c1d46954d1d..0e9e9b928d9 100644 --- a/C4/HoldsQueue.pm +++ b/C4/HoldsQueue.pm @@ -486,12 +486,12 @@ RETRY: while (1) { return [] if $num_agents == 0 || $num_tasks == 0; - if ( $num_tasks < $num_agents && @remaining ) { + if ( $num_tasks <= $num_agents && @remaining ) { # On retry, move tasks from @remaining to @requests up to # the number of agents. my $nr = scalar(@remaining); - my $na = $num_agents - $num_tasks; + my $na = $num_agents - $num_tasks || 1; my $nm = $nr < $na ? $nr : $na; push @requests, ( splice @remaining, 0, $nm ); $num_tasks += $nm; @@ -575,9 +575,9 @@ RETRY: } } - $num_tasks = scalar(@requests); + $num_tasks = scalar(@requests) + scalar(@remaining); - if ( $num_agents > $num_tasks && @remaining ) { + if ( $num_agents >= $num_tasks && @remaining ) { $r = $num_tasks; @candidate_tasks = ( (1) x $num_tasks ); -- 2.39.5