Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data race on measurementFields #6188

Closed
jwilder opened this issue Apr 1, 2016 · 0 comments · Fixed by #6190
Closed

Data race on measurementFields #6188

jwilder opened this issue Apr 1, 2016 · 0 comments · Fixed by #6190

Comments

@jwilder
Copy link
Contributor

jwilder commented Apr 1, 2016

Bug report

System info:

0.12, golang 1.6 GOGC=1800

Steps to reproduce:

  1. go install -race ./cmd/influxd
  2. GOGC=1800 influxd
  3. influx_stress

Actual behavior:

WARNING: DATA RACE
Write by goroutine 62:
  runtime.mapassign1()
      /usr/local/go1.6/src/runtime/hashmap.go:429 +0x0
  github.com/influxdata/influxdb/tsdb.(*Shard).createFieldsAndMeasurements()
      /Users/jason/go/src/github.com/influxdata/influxdb/tsdb/shard.go:343 +0x3ad
  github.com/influxdata/influxdb/tsdb.(*Shard).WritePoints()
      /Users/jason/go/src/github.com/influxdata/influxdb/tsdb/shard.go:258 +0x51e
  github.com/influxdata/influxdb/tsdb.(*Store).WriteToShard()
      /Users/jason/go/src/github.com/influxdata/influxdb/tsdb/store.go:632 +0x1e6
  github.com/influxdata/influxdb/cluster.(*PointsWriter).writeToShard()
      /Users/jason/go/src/github.com/influxdata/influxdb/cluster/points_writer.go:249 +0x12a
  github.com/influxdata/influxdb/cluster.(*PointsWriter).WritePoints.func1()
      /Users/jason/go/src/github.com/influxdata/influxdb/cluster/points_writer.go:212 +0x9a

Previous read by goroutine 118:
  runtime.mapaccess1_faststr()
      /usr/local/go1.6/src/runtime/hashmap_fast.go:193 +0x0
  github.com/influxdata/influxdb/tsdb/engine/tsm1.(*Engine).buildCursor()
      /Users/jason/go/src/github.com/influxdata/influxdb/tsdb/engine/tsm1/engine.go:902 +0xd1
  github.com/influxdata/influxdb/tsdb/engine/tsm1.(*Engine).createVarRefSeriesIterator()
      /Users/jason/go/src/github.com/influxdata/influxdb/tsdb/engine/tsm1/engine.go:877 +0xa2c
  github.com/influxdata/influxdb/tsdb/engine/tsm1.(*Engine).createVarRefIterator.func1()
      /Users/jason/go/src/github.com/influxdata/influxdb/tsdb/engine/tsm1/engine.go:804 +0x9fb
  github.com/influxdata/influxdb/tsdb/engine/tsm1.(*Engine).createVarRefIterator()
      /Users/jason/go/src/github.com/influxdata/influxdb/tsdb/engine/tsm1/engine.go:815 +0xcd
  github.com/influxdata/influxdb/tsdb/engine/tsm1.(*Engine).CreateIterator()
      /Users/jason/go/src/github.com/influxdata/influxdb/tsdb/engine/tsm1/engine.go:682 +0x1f7
  github.com/influxdata/influxdb/tsdb.(*Shard).CreateIterator()
      /Users/jason/go/src/github.com/influxdata/influxdb/tsdb/shard.go:437 +0x1e3
  github.com/influxdata/influxdb/tsdb.(*shardIteratorCreator).CreateIterator()
      /Users/jason/go/src/github.com/influxdata/influxdb/tsdb/shard.go:907 +0x8f
  github.com/influxdata/influxdb/influxql.IteratorCreators.CreateIterator.func1()
      /Users/jason/go/src/github.com/influxdata/influxdb/influxql/iterator.go:483 +0x12c
  github.com/influxdata/influxdb/influxql.IteratorCreators.CreateIterator()
      /Users/jason/go/src/github.com/influxdata/influxdb/influxql/iterator.go:490 +0xe8
  github.com/influxdata/influxdb/influxql.(*IteratorCreators).CreateIterator()
      <autogenerated>:152 +0x10e
  github.com/influxdata/influxdb/influxql.buildExprIterator.func1()
      /Users/jason/go/src/github.com/influxdata/influxdb/influxql/select.go:258 +0x1407
  github.com/influxdata/influxdb/influxql.buildExprIterator()
      /Users/jason/go/src/github.com/influxdata/influxdb/influxql/select.go:344 +0x1e77
  github.com/influxdata/influxdb/influxql.buildFieldIterators.func1()
      /Users/jason/go/src/github.com/influxdata/influxdb/influxql/select.go:154 +0x7b0
  github.com/influxdata/influxdb/influxql.buildFieldIterators()
      /Users/jason/go/src/github.com/influxdata/influxdb/influxql/select.go:190 +0x108
  github.com/influxdata/influxdb/influxql.Select()
      /Users/jason/go/src/github.com/influxdata/influxdb/influxql/select.go:81 +0x11f6
  github.com/influxdata/influxdb/cluster.(*QueryExecutor).executeSelectStatement()
      /Users/jason/go/src/github.com/influxdata/influxdb/cluster/query_executor.go:500 +0xb92
  github.com/influxdata/influxdb/cluster.(*QueryExecutor).executeQuery()
      /Users/jason/go/src/github.com/influxdata/influxdb/cluster/query_executor.go:146 +0xdcc
jwilder added a commit that referenced this issue Apr 2, 2016
Both Shard and Engine had the same reference to the measurementField map,
but they each protected it with their own locks.  This causes a race when
write and queries are occurring because writes can add new fields to the
map while queries are reading from it.

The fix moves the ownership to the Engine and provides protected accessors
to that Shard now users.  For the most parts, the access on shard were old
dead code.

Fixing the measurementFields map race created a new race on the internal
fields map.  This is now unexported and protected via MeasurementFields
exported funcs.

Fixes #6188
jsternberg pushed a commit that referenced this issue Apr 6, 2016
Both Shard and Engine had the same reference to the measurementField map,
but they each protected it with their own locks.  This causes a race when
write and queries are occurring because writes can add new fields to the
map while queries are reading from it.

The fix moves the ownership to the Engine and provides protected accessors
to that Shard now users.  For the most parts, the access on shard were old
dead code.

Fixing the measurementFields map race created a new race on the internal
fields map.  This is now unexported and protected via MeasurementFields
exported funcs.

Fixes #6188
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant