14325: Start up immediately if there are no stale locks.
authorTom Clegg <tclegg@veritasgenetics.com>
Tue, 12 Feb 2019 19:17:10 +0000 (14:17 -0500)
committerTom Clegg <tclegg@veritasgenetics.com>
Fri, 15 Feb 2019 05:03:08 +0000 (00:03 -0500)
...instead of waiting for the pool to send a notification to trigger
the first loop iteration.

refs #14325

Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tclegg@veritasgenetics.com>

lib/dispatchcloud/scheduler/fix_stale_locks.go

index 4bd27021c675d1c8ce40753d131d0631041ea59c..148b653c2e52305b2ece2255c49d98bf6cb72f50 100644 (file)
@@ -23,7 +23,7 @@ func (sch *Scheduler) fixStaleLocks() {
        var stale []string
        timeout := time.NewTimer(sch.staleLockTimeout)
 waiting:
-       for {
+       for sch.pool.CountWorkers()[worker.StateUnknown] > 0 {
                running := sch.pool.Running()
                qEntries, _ := sch.queue.Entries()
 
@@ -43,11 +43,6 @@ waiting:
 
                select {
                case <-wp:
-                       // Stop waiting if all workers have been
-                       // contacted.
-                       if sch.pool.CountWorkers()[worker.StateUnknown] == 0 {
-                               break waiting
-                       }
                case <-timeout.C:
                        // Give up.
                        break waiting