From 395e8e3e3dc1d48c1ba4cc31bc06f1fc4bf2d47b Mon Sep 17 00:00:00 2001 From: Pradyumna Kaushik Date: Tue, 29 Nov 2016 22:26:55 -0500 Subject: [PATCH] synchronized operations on tasksRunning and hence prevented the previously occuring race condition. --- schedulers/proactiveclusterwidecappingfcfs.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/schedulers/proactiveclusterwidecappingfcfs.go b/schedulers/proactiveclusterwidecappingfcfs.go index 37fa19a..a96d496 100644 --- a/schedulers/proactiveclusterwidecappingfcfs.go +++ b/schedulers/proactiveclusterwidecappingfcfs.go @@ -339,7 +339,9 @@ func (s *ProactiveClusterwideCapFCFS) StatusUpdate(driver sched.SchedulerDriver, log.Printf("Received task status [%s] for task [%s]\n", NameFor(status.State), *status.TaskId.Value) if *status.State == mesos.TaskState_TASK_RUNNING { + fcfsMutex.Lock() s.tasksRunning++ + fcfsMutex.Unlock() } else if IsTerminal(status.State) { delete(s.running[status.GetSlaveId().GoString()], *status.TaskId.Value) // Need to remove the task from the window of tasks. @@ -365,7 +367,9 @@ func (s *ProactiveClusterwideCapFCFS) StatusUpdate(driver sched.SchedulerDriver, log.Println(err) } + fcfsMutex.Lock() s.tasksRunning-- + fcfsMutex.Unlock() if s.tasksRunning == 0 { select { case <-s.Shutdown: