Skip to content

Commit

Permalink
Merge pull request #3982 from influxdb/dgn-fix-3979
Browse files Browse the repository at this point in the history
fix #3979: fix race in CQ service
  • Loading branch information
dgnorton committed Sep 4, 2015
2 parents 815faf3 + dce666e commit 548b898
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions services/continuous_querier/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ type Service struct {
Logger *log.Logger
loggingEnabled bool
// lastRuns maps CQ name to last time it was run.
mu sync.RWMutex
lastRuns map[string]time.Time
stop chan struct{}
wg *sync.WaitGroup
Expand Down Expand Up @@ -156,6 +157,8 @@ func (s *Service) Run(database, name string, t time.Time) error {
}

// Loop through databases.
s.mu.Lock()
defer s.mu.Unlock()
for _, db := range dbs {
// Loop through CQs in each DB executing the ones that match name.
for _, cq := range db.ContinuousQueries {
Expand Down Expand Up @@ -227,6 +230,8 @@ func (s *Service) ExecuteContinuousQuery(dbi *meta.DatabaseInfo, cqi *meta.Conti
}

// Get the last time this CQ was run from the service's cache.
s.mu.Lock()
defer s.mu.Unlock()
cq.LastRun = s.lastRuns[cqi.Name]

// Set the retention policy to default if it wasn't specified in the query.
Expand Down

0 comments on commit 548b898

Please sign in to comment.