diff --git a/stress/basic.go b/stress/basic.go index 67c6b15364..99ec650fef 100644 --- a/stress/basic.go +++ b/stress/basic.go @@ -659,7 +659,9 @@ 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["method"] = method fields := map[string]interface{}{ "response_time": float64(p.Timer.Elapsed()), @@ -668,10 +670,12 @@ 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, Precision: "ns", }) + o.mu.Unlock() } } diff --git a/stress/config.go b/stress/config.go index 6749986b6a..35b8bb0b13 100644 --- a/stress/config.go +++ b/stress/config.go @@ -5,6 +5,7 @@ import ( "fmt" "github.com/BurntSushi/toml" "strings" + "sync" ) // Config is a struct for the Stress test configuration @@ -102,6 +103,7 @@ type outputConfig struct { tags map[string]string addr string database string + mu sync.Mutex } func (t *outputConfig) SetParams(addr, db string) {