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

Fix panic when droppping measurement while writing to it concurrently #3167

Merged
merged 1 commit into from
Jun 29, 2015

Conversation

jwilder
Copy link
Contributor

@jwilder jwilder commented Jun 26, 2015

There is a race when writing points and dropping measurements where the fields are removed from the index while points are attempting to use them for encoding.

Produces this panic in 0.9.1-rc1

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x8 pc=0x19c625]

goroutine 2744 [running]:
github.com/influxdb/influxdb/tsdb.(*Shard).WritePoints(0xc2081ac000, 0xc21b450000, 0x1388, 0x1800, 0x0, 0x0)
    /Users/jason/go/src/github.com/influxdb/influxdb/tsdb/shard.go:246 +0x415
github.com/influxdb/influxdb/tsdb.(*Store).WriteToShard(0xc208034be0, 0x6, 0xc21b450000, 0x1388, 0x1800, 0x0, 0x0)
    /Users/jason/go/src/github.com/influxdb/influxdb/tsdb/store.go:278 +0xf7
github.com/influxdb/influxdb/cluster.func·002(0x6, 0x1, 0xc21b450000, 0x1388, 0x1800)
    /Users/jason/go/src/github.com/influxdb/influxdb/cluster/points_writer.go:241 +0xfc
created by github.com/influxdb/influxdb/cluster.(*PointsWriter).writeToShard
    /Users/jason/go/src/github.com/influxdb/influxdb/cluster/points_writer.go:271 +0x30b

Fixes #2608

@@ -243,6 +243,13 @@ func (s *Shard) WritePoints(points []Point) error {
s.mu.RLock()
mf := s.measurementFields[p.Name()]
s.mu.RUnlock()

// If a measurement is dropped while writes for it are in progress, this could be nil
// See #2608
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: I haven't seen us do this before i.e. reference bug numbers. I think the comment is pretty good as it is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the bug number reference.

@otoolep
Copy link
Contributor

otoolep commented Jun 26, 2015

Seems reasonable.+1

jwilder added a commit that referenced this pull request Jun 29, 2015
Fix panic when droppping measurement while writing to it concurrently
@jwilder jwilder merged commit eb71f78 into master Jun 29, 2015
@jwilder jwilder deleted the jw-2608 branch June 29, 2015 20:05
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 this pull request may close these issues.

2 participants