Skip to content
This repository has been archived by the owner on May 23, 2024. It is now read-only.

Commit

Permalink
🐛 Fixing deadlock issue with the scheduler shutdown and writing state…
Browse files Browse the repository at this point in the history
… to S3
  • Loading branch information
peteclark-ft committed Jun 1, 2017
1 parent 02907d2 commit 3a88a1d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions scheduler/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,6 @@ func (s *defaultScheduler) DeleteCycle(cycleID string) error {
}

func (s *defaultScheduler) saveCycleMetadata() {
s.cycleLock.RLock()
defer s.cycleLock.RUnlock()

log.Info("Saving cycle metadata to S3.")

for _, cycle := range s.cycles {
Expand Down Expand Up @@ -160,7 +157,12 @@ func (s *defaultScheduler) Start() error {
time.Sleep(startInterval)
}

s.checkpointHandler.start(s.saveCycleMetadata)
s.checkpointHandler.start(func() {
s.cycleLock.RLock()
defer s.cycleLock.RUnlock()

s.saveCycleMetadata()
})

return nil
}
Expand Down Expand Up @@ -246,6 +248,7 @@ func (s *defaultScheduler) toggleHandler(toggleValue string, requestType int) {
return
}
}

if requestType == automatic {
s.state.setState(autoDisabled)
} else {
Expand Down

0 comments on commit 3a88a1d

Please sign in to comment.