Skip to content

Commit

Permalink
Copy tags in influx_stress to avoid a concurrent write panic on a map
Browse files Browse the repository at this point in the history
Removing lock from the same object as that object never does anything
except for having attributes read.
  • Loading branch information
jsternberg committed Jul 21, 2016
1 parent da10220 commit b1fdf27
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ With this release the systemd configuration files for InfluxDB will use the syst
- [#6946](https://github.com/influxdata/influxdb/issues/6946): Duplicate data for the same timestamp
- [#7043](https://github.com/influxdata/influxdb/pull/7043): Remove limiter from walkShards
- [#5501](https://github.com/influxdata/influxdb/issues/5501): Queries against files that have just been compacted need to point to new files
- [#7032](https://github.com/influxdata/influxdb/pull/7032): Copy tags in influx_stress to avoid a concurrent write panic on a map.

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

Expand Down
9 changes: 4 additions & 5 deletions stress/basic.go
Original file line number Diff line number Diff line change
Expand Up @@ -678,9 +678,10 @@ func (o *outputConfig) HTTPHandler(method string) func(r <-chan response, rt *Ti
Precision: "ns",
})
for p := range r {
o.mu.Lock()
tags := o.tags
o.mu.Unlock()
tags := make(map[string]string, len(o.tags))
for k, v := range o.tags {
tags[k] = v
}
tags["method"] = method
fields := map[string]interface{}{
"response_time": float64(p.Timer.Elapsed()),
Expand All @@ -689,13 +690,11 @@ func (o *outputConfig) HTTPHandler(method string) func(r <-chan response, rt *Ti
bp.AddPoint(pt)
if len(bp.Points())%1000 == 0 && len(bp.Points()) != 0 {
c.Write(bp)
o.mu.Lock()
bp, _ = client.NewBatchPoints(client.BatchPointsConfig{
Database: o.database,
RetentionPolicy: o.retentionPolicy,
Precision: "ns",
})
o.mu.Unlock()
}
}

Expand Down
2 changes: 0 additions & 2 deletions stress/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"flag"
"fmt"
"strings"
"sync"

"github.com/BurntSushi/toml"
)
Expand Down Expand Up @@ -105,7 +104,6 @@ type outputConfig struct {
addr string
database string
retentionPolicy string
mu sync.Mutex
}

func (t *outputConfig) SetParams(addr, db, rp string) {
Expand Down

0 comments on commit b1fdf27

Please sign in to comment.