Skip to content

Commit

Permalink
Ensure CQ id names can't clash
Browse files Browse the repository at this point in the history
  • Loading branch information
e-dard committed Jul 28, 2016
1 parent d688676 commit 9a2efaf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ With this release the systemd configuration files for InfluxDB will use the syst
- [#6595](https://github.com/influxdata/influxdb/issues/6595): Fix full compactions conflicting with level compactions
- [#7081](https://github.com/influxdata/influxdb/issues/7081): Hardcode auto generated RP names to autogen
- [#7088](https://github.com/influxdata/influxdb/pull/7088): Fix UDP pointsRx being incremented twice.
- [#7080](https://github.com/influxdata/influxdb/pull/7080): Ensure IDs can't clash when managing Continuous Queries.

## v0.13.0 [2016-05-12]

Expand Down
8 changes: 6 additions & 2 deletions services/continuous_querier/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ const (
// a select statement, passing zero tells it not to chunk results.
// Only applies to raw queries.
NoChunkingSize = 0

// idDelimiter is used as a delimiter when creating a unique name for a
// Continuous Query.
idDelimiter = string(rune(31)) // unit separator
)

// Statistics for the CQ service.
Expand Down Expand Up @@ -175,7 +179,7 @@ func (s *Service) Run(database, name string, t time.Time) error {
for _, cq := range db.ContinuousQueries {
if name == "" || cq.Name == name {
// Remove the last run time for the CQ
id := fmt.Sprintf("%s:%s", db.Name, cq.Name)
id := fmt.Sprintf("%s%s%s", db.Name, idDelimiter, cq.Name)
if _, ok := s.lastRuns[id]; ok {
delete(s.lastRuns, id)
}
Expand Down Expand Up @@ -265,7 +269,7 @@ 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()
id := fmt.Sprintf("%s:%s", dbi.Name, cqi.Name)
id := fmt.Sprintf("%s%s%s", dbi.Name, idDelimiter, cqi.Name)
cq.LastRun, cq.HasRun = s.lastRuns[id]

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

0 comments on commit 9a2efaf

Please sign in to comment.