Fix panic: runtime error: index out of range
There was a fix in 5b1791, but is not present in the current branch likely due to a rebase issue. The current code panics with a query like: select value from cpu group by host order by time desc limit 1 This fixes the panic as well as prevents #5193 from re-occurring. The issue is that agressively closing the cursors clears out the seeks slice so re-seeking will fail.pull/5623/head
parent
2f1e83427b
commit
0ce6dd1304
|
@ -30,7 +30,7 @@ import (
|
||||||
"github.com/influxdata/influxdb/services/udp"
|
"github.com/influxdata/influxdb/services/udp"
|
||||||
"github.com/influxdata/influxdb/tcp"
|
"github.com/influxdata/influxdb/tcp"
|
||||||
"github.com/influxdata/influxdb/tsdb"
|
"github.com/influxdata/influxdb/tsdb"
|
||||||
client "github.com/influxdb/usage-client/v1"
|
client "github.com/influxdata/usage-client/v1"
|
||||||
// Initialize the engine packages
|
// Initialize the engine packages
|
||||||
_ "github.com/influxdata/influxdb/tsdb/engine"
|
_ "github.com/influxdata/influxdb/tsdb/engine"
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
// Generated by tmpl
|
// Generated by tmpl
|
||||||
// https://github.com/benbjohnson/tmpl
|
// https://github.com/benbjohnson/tmpl
|
||||||
|
//
|
||||||
|
// DO NOT EDIT!
|
||||||
|
// Source: iterator.gen.go.tmpl
|
||||||
|
|
||||||
package tsm1
|
package tsm1
|
||||||
|
|
||||||
|
@ -240,7 +243,6 @@ func (c *floatAscendingCursor) peekCache() (t int64, v float64) {
|
||||||
// peekTSM returns the current time/value from tsm.
|
// peekTSM returns the current time/value from tsm.
|
||||||
func (c *floatAscendingCursor) peekTSM() (t int64, v float64) {
|
func (c *floatAscendingCursor) peekTSM() (t int64, v float64) {
|
||||||
if c.tsm.pos < 0 || c.tsm.pos >= len(c.tsm.values) {
|
if c.tsm.pos < 0 || c.tsm.pos >= len(c.tsm.values) {
|
||||||
c.tsm.keyCursor.Close()
|
|
||||||
return tsdb.EOF, math.NaN()
|
return tsdb.EOF, math.NaN()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,7 +296,6 @@ func (c *floatAscendingCursor) nextTSM() {
|
||||||
c.tsm.keyCursor.Next()
|
c.tsm.keyCursor.Next()
|
||||||
c.tsm.values, _ = c.tsm.keyCursor.ReadFloatBlock(c.tsm.buf)
|
c.tsm.values, _ = c.tsm.keyCursor.ReadFloatBlock(c.tsm.buf)
|
||||||
if len(c.tsm.values) == 0 {
|
if len(c.tsm.values) == 0 {
|
||||||
c.tsm.keyCursor.Close()
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.tsm.pos = 0
|
c.tsm.pos = 0
|
||||||
|
@ -352,7 +353,6 @@ func (c *floatDescendingCursor) peekCache() (t int64, v float64) {
|
||||||
// peekTSM returns the current time/value from tsm.
|
// peekTSM returns the current time/value from tsm.
|
||||||
func (c *floatDescendingCursor) peekTSM() (t int64, v float64) {
|
func (c *floatDescendingCursor) peekTSM() (t int64, v float64) {
|
||||||
if c.tsm.pos < 0 || c.tsm.pos >= len(c.tsm.values) {
|
if c.tsm.pos < 0 || c.tsm.pos >= len(c.tsm.values) {
|
||||||
c.tsm.keyCursor.Close()
|
|
||||||
return tsdb.EOF, math.NaN()
|
return tsdb.EOF, math.NaN()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -406,7 +406,6 @@ func (c *floatDescendingCursor) nextTSM() {
|
||||||
c.tsm.keyCursor.Next()
|
c.tsm.keyCursor.Next()
|
||||||
c.tsm.values, _ = c.tsm.keyCursor.ReadFloatBlock(c.tsm.buf)
|
c.tsm.values, _ = c.tsm.keyCursor.ReadFloatBlock(c.tsm.buf)
|
||||||
if len(c.tsm.values) == 0 {
|
if len(c.tsm.values) == 0 {
|
||||||
c.tsm.keyCursor.Close()
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.tsm.pos = 0
|
c.tsm.pos = 0
|
||||||
|
@ -576,7 +575,6 @@ func (c *integerAscendingCursor) peekCache() (t int64, v int64) {
|
||||||
// peekTSM returns the current time/value from tsm.
|
// peekTSM returns the current time/value from tsm.
|
||||||
func (c *integerAscendingCursor) peekTSM() (t int64, v int64) {
|
func (c *integerAscendingCursor) peekTSM() (t int64, v int64) {
|
||||||
if c.tsm.pos < 0 || c.tsm.pos >= len(c.tsm.values) {
|
if c.tsm.pos < 0 || c.tsm.pos >= len(c.tsm.values) {
|
||||||
c.tsm.keyCursor.Close()
|
|
||||||
return tsdb.EOF, 0
|
return tsdb.EOF, 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -630,7 +628,6 @@ func (c *integerAscendingCursor) nextTSM() {
|
||||||
c.tsm.keyCursor.Next()
|
c.tsm.keyCursor.Next()
|
||||||
c.tsm.values, _ = c.tsm.keyCursor.ReadIntegerBlock(c.tsm.buf)
|
c.tsm.values, _ = c.tsm.keyCursor.ReadIntegerBlock(c.tsm.buf)
|
||||||
if len(c.tsm.values) == 0 {
|
if len(c.tsm.values) == 0 {
|
||||||
c.tsm.keyCursor.Close()
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.tsm.pos = 0
|
c.tsm.pos = 0
|
||||||
|
@ -688,7 +685,6 @@ func (c *integerDescendingCursor) peekCache() (t int64, v int64) {
|
||||||
// peekTSM returns the current time/value from tsm.
|
// peekTSM returns the current time/value from tsm.
|
||||||
func (c *integerDescendingCursor) peekTSM() (t int64, v int64) {
|
func (c *integerDescendingCursor) peekTSM() (t int64, v int64) {
|
||||||
if c.tsm.pos < 0 || c.tsm.pos >= len(c.tsm.values) {
|
if c.tsm.pos < 0 || c.tsm.pos >= len(c.tsm.values) {
|
||||||
c.tsm.keyCursor.Close()
|
|
||||||
return tsdb.EOF, 0
|
return tsdb.EOF, 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -742,7 +738,6 @@ func (c *integerDescendingCursor) nextTSM() {
|
||||||
c.tsm.keyCursor.Next()
|
c.tsm.keyCursor.Next()
|
||||||
c.tsm.values, _ = c.tsm.keyCursor.ReadIntegerBlock(c.tsm.buf)
|
c.tsm.values, _ = c.tsm.keyCursor.ReadIntegerBlock(c.tsm.buf)
|
||||||
if len(c.tsm.values) == 0 {
|
if len(c.tsm.values) == 0 {
|
||||||
c.tsm.keyCursor.Close()
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.tsm.pos = 0
|
c.tsm.pos = 0
|
||||||
|
@ -912,7 +907,6 @@ func (c *stringAscendingCursor) peekCache() (t int64, v string) {
|
||||||
// peekTSM returns the current time/value from tsm.
|
// peekTSM returns the current time/value from tsm.
|
||||||
func (c *stringAscendingCursor) peekTSM() (t int64, v string) {
|
func (c *stringAscendingCursor) peekTSM() (t int64, v string) {
|
||||||
if c.tsm.pos < 0 || c.tsm.pos >= len(c.tsm.values) {
|
if c.tsm.pos < 0 || c.tsm.pos >= len(c.tsm.values) {
|
||||||
c.tsm.keyCursor.Close()
|
|
||||||
return tsdb.EOF, ""
|
return tsdb.EOF, ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -966,7 +960,6 @@ func (c *stringAscendingCursor) nextTSM() {
|
||||||
c.tsm.keyCursor.Next()
|
c.tsm.keyCursor.Next()
|
||||||
c.tsm.values, _ = c.tsm.keyCursor.ReadStringBlock(c.tsm.buf)
|
c.tsm.values, _ = c.tsm.keyCursor.ReadStringBlock(c.tsm.buf)
|
||||||
if len(c.tsm.values) == 0 {
|
if len(c.tsm.values) == 0 {
|
||||||
c.tsm.keyCursor.Close()
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.tsm.pos = 0
|
c.tsm.pos = 0
|
||||||
|
@ -1024,7 +1017,6 @@ func (c *stringDescendingCursor) peekCache() (t int64, v string) {
|
||||||
// peekTSM returns the current time/value from tsm.
|
// peekTSM returns the current time/value from tsm.
|
||||||
func (c *stringDescendingCursor) peekTSM() (t int64, v string) {
|
func (c *stringDescendingCursor) peekTSM() (t int64, v string) {
|
||||||
if c.tsm.pos < 0 || c.tsm.pos >= len(c.tsm.values) {
|
if c.tsm.pos < 0 || c.tsm.pos >= len(c.tsm.values) {
|
||||||
c.tsm.keyCursor.Close()
|
|
||||||
return tsdb.EOF, ""
|
return tsdb.EOF, ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1078,7 +1070,6 @@ func (c *stringDescendingCursor) nextTSM() {
|
||||||
c.tsm.keyCursor.Next()
|
c.tsm.keyCursor.Next()
|
||||||
c.tsm.values, _ = c.tsm.keyCursor.ReadStringBlock(c.tsm.buf)
|
c.tsm.values, _ = c.tsm.keyCursor.ReadStringBlock(c.tsm.buf)
|
||||||
if len(c.tsm.values) == 0 {
|
if len(c.tsm.values) == 0 {
|
||||||
c.tsm.keyCursor.Close()
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.tsm.pos = 0
|
c.tsm.pos = 0
|
||||||
|
@ -1248,7 +1239,6 @@ func (c *booleanAscendingCursor) peekCache() (t int64, v bool) {
|
||||||
// peekTSM returns the current time/value from tsm.
|
// peekTSM returns the current time/value from tsm.
|
||||||
func (c *booleanAscendingCursor) peekTSM() (t int64, v bool) {
|
func (c *booleanAscendingCursor) peekTSM() (t int64, v bool) {
|
||||||
if c.tsm.pos < 0 || c.tsm.pos >= len(c.tsm.values) {
|
if c.tsm.pos < 0 || c.tsm.pos >= len(c.tsm.values) {
|
||||||
c.tsm.keyCursor.Close()
|
|
||||||
return tsdb.EOF, false
|
return tsdb.EOF, false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1302,7 +1292,6 @@ func (c *booleanAscendingCursor) nextTSM() {
|
||||||
c.tsm.keyCursor.Next()
|
c.tsm.keyCursor.Next()
|
||||||
c.tsm.values, _ = c.tsm.keyCursor.ReadBooleanBlock(c.tsm.buf)
|
c.tsm.values, _ = c.tsm.keyCursor.ReadBooleanBlock(c.tsm.buf)
|
||||||
if len(c.tsm.values) == 0 {
|
if len(c.tsm.values) == 0 {
|
||||||
c.tsm.keyCursor.Close()
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.tsm.pos = 0
|
c.tsm.pos = 0
|
||||||
|
@ -1360,7 +1349,6 @@ func (c *booleanDescendingCursor) peekCache() (t int64, v bool) {
|
||||||
// peekTSM returns the current time/value from tsm.
|
// peekTSM returns the current time/value from tsm.
|
||||||
func (c *booleanDescendingCursor) peekTSM() (t int64, v bool) {
|
func (c *booleanDescendingCursor) peekTSM() (t int64, v bool) {
|
||||||
if c.tsm.pos < 0 || c.tsm.pos >= len(c.tsm.values) {
|
if c.tsm.pos < 0 || c.tsm.pos >= len(c.tsm.values) {
|
||||||
c.tsm.keyCursor.Close()
|
|
||||||
return tsdb.EOF, false
|
return tsdb.EOF, false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1414,7 +1402,6 @@ func (c *booleanDescendingCursor) nextTSM() {
|
||||||
c.tsm.keyCursor.Next()
|
c.tsm.keyCursor.Next()
|
||||||
c.tsm.values, _ = c.tsm.keyCursor.ReadBooleanBlock(c.tsm.buf)
|
c.tsm.values, _ = c.tsm.keyCursor.ReadBooleanBlock(c.tsm.buf)
|
||||||
if len(c.tsm.values) == 0 {
|
if len(c.tsm.values) == 0 {
|
||||||
c.tsm.keyCursor.Close()
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.tsm.pos = 0
|
c.tsm.pos = 0
|
||||||
|
|
|
@ -239,7 +239,6 @@ func (c *{{.name}}AscendingCursor) peekCache() (t int64, v {{.Type}}) {
|
||||||
// peekTSM returns the current time/value from tsm.
|
// peekTSM returns the current time/value from tsm.
|
||||||
func (c *{{.name}}AscendingCursor) peekTSM() (t int64, v {{.Type}}) {
|
func (c *{{.name}}AscendingCursor) peekTSM() (t int64, v {{.Type}}) {
|
||||||
if c.tsm.pos < 0 || c.tsm.pos >= len(c.tsm.values) {
|
if c.tsm.pos < 0 || c.tsm.pos >= len(c.tsm.values) {
|
||||||
c.tsm.keyCursor.Close()
|
|
||||||
return tsdb.EOF, {{.Nil}}
|
return tsdb.EOF, {{.Nil}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -293,7 +292,6 @@ func (c *{{.name}}AscendingCursor) nextTSM() {
|
||||||
c.tsm.keyCursor.Next()
|
c.tsm.keyCursor.Next()
|
||||||
c.tsm.values, _ = c.tsm.keyCursor.Read{{.Name}}Block(c.tsm.buf)
|
c.tsm.values, _ = c.tsm.keyCursor.Read{{.Name}}Block(c.tsm.buf)
|
||||||
if len(c.tsm.values) == 0 {
|
if len(c.tsm.values) == 0 {
|
||||||
c.tsm.keyCursor.Close()
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.tsm.pos = 0
|
c.tsm.pos = 0
|
||||||
|
@ -351,7 +349,6 @@ func (c *{{.name}}DescendingCursor) peekCache() (t int64, v {{.Type}}) {
|
||||||
// peekTSM returns the current time/value from tsm.
|
// peekTSM returns the current time/value from tsm.
|
||||||
func (c *{{.name}}DescendingCursor) peekTSM() (t int64, v {{.Type}}) {
|
func (c *{{.name}}DescendingCursor) peekTSM() (t int64, v {{.Type}}) {
|
||||||
if c.tsm.pos < 0 || c.tsm.pos >= len(c.tsm.values) {
|
if c.tsm.pos < 0 || c.tsm.pos >= len(c.tsm.values) {
|
||||||
c.tsm.keyCursor.Close()
|
|
||||||
return tsdb.EOF, {{.Nil}}
|
return tsdb.EOF, {{.Nil}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -405,7 +402,6 @@ func (c *{{.name}}DescendingCursor) nextTSM() {
|
||||||
c.tsm.keyCursor.Next()
|
c.tsm.keyCursor.Next()
|
||||||
c.tsm.values, _ = c.tsm.keyCursor.Read{{.Name}}Block(c.tsm.buf)
|
c.tsm.values, _ = c.tsm.keyCursor.Read{{.Name}}Block(c.tsm.buf)
|
||||||
if len(c.tsm.values) == 0 {
|
if len(c.tsm.values) == 0 {
|
||||||
c.tsm.keyCursor.Close()
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.tsm.pos = 0
|
c.tsm.pos = 0
|
||||||
|
|
Loading…
Reference in New Issue