Skip to content

Commit

Permalink
fix(tsdb/engine/tsm1): Fix panic when closing cursor multiple times
Browse files Browse the repository at this point in the history
Fixes #9909
  • Loading branch information
stuartcarnie committed May 29, 2018
1 parent bb31376 commit 0253f6f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
30 changes: 20 additions & 10 deletions tsdb/engine/tsm1/batch_cursor.gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,10 @@ func (c *floatAscendingBatchCursor) Err() error { return nil }

// close closes the cursor and any dependent cursors.
func (c *floatAscendingBatchCursor) Close() {
c.tsm.keyCursor.Close()
c.tsm.keyCursor = nil
if c.tsm.keyCursor != nil {
c.tsm.keyCursor.Close()
c.tsm.keyCursor = nil
}
c.cache.values = nil
c.tsm.values = nil
}
Expand Down Expand Up @@ -398,8 +400,10 @@ func (c *integerAscendingBatchCursor) Err() error { return nil }

// close closes the cursor and any dependent cursors.
func (c *integerAscendingBatchCursor) Close() {
c.tsm.keyCursor.Close()
c.tsm.keyCursor = nil
if c.tsm.keyCursor != nil {
c.tsm.keyCursor.Close()
c.tsm.keyCursor = nil
}
c.cache.values = nil
c.tsm.values = nil
}
Expand Down Expand Up @@ -697,8 +701,10 @@ func (c *unsignedAscendingBatchCursor) Err() error { return nil }

// close closes the cursor and any dependent cursors.
func (c *unsignedAscendingBatchCursor) Close() {
c.tsm.keyCursor.Close()
c.tsm.keyCursor = nil
if c.tsm.keyCursor != nil {
c.tsm.keyCursor.Close()
c.tsm.keyCursor = nil
}
c.cache.values = nil
c.tsm.values = nil
}
Expand Down Expand Up @@ -996,8 +1002,10 @@ func (c *stringAscendingBatchCursor) Err() error { return nil }

// close closes the cursor and any dependent cursors.
func (c *stringAscendingBatchCursor) Close() {
c.tsm.keyCursor.Close()
c.tsm.keyCursor = nil
if c.tsm.keyCursor != nil {
c.tsm.keyCursor.Close()
c.tsm.keyCursor = nil
}
c.cache.values = nil
c.tsm.values = nil
}
Expand Down Expand Up @@ -1295,8 +1303,10 @@ func (c *booleanAscendingBatchCursor) Err() error { return nil }

// close closes the cursor and any dependent cursors.
func (c *booleanAscendingBatchCursor) Close() {
c.tsm.keyCursor.Close()
c.tsm.keyCursor = nil
if c.tsm.keyCursor != nil {
c.tsm.keyCursor.Close()
c.tsm.keyCursor = nil
}
c.cache.values = nil
c.tsm.values = nil
}
Expand Down
6 changes: 4 additions & 2 deletions tsdb/engine/tsm1/batch_cursor.gen.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,10 @@ func (c *{{.name}}AscendingBatchCursor) Err() error { return nil }

// close closes the cursor and any dependent cursors.
func (c *{{.name}}AscendingBatchCursor) Close() {
c.tsm.keyCursor.Close()
c.tsm.keyCursor = nil
if c.tsm.keyCursor != nil {
c.tsm.keyCursor.Close()
c.tsm.keyCursor = nil
}
c.cache.values = nil
c.tsm.values = nil
}
Expand Down

0 comments on commit 0253f6f

Please sign in to comment.