diff --git a/CHANGELOG.md b/CHANGELOG.md index 25a37ac1978..57034a30dfd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,8 @@ - [#8064](https://github.com/influxdata/influxdb/issues/8064): Forbid wildcards in binary expressions. - [#8148](https://github.com/influxdata/influxdb/issues/8148): Fix fill(linear) when multiple series exist and there are null values. - [#7995](https://github.com/influxdata/influxdb/issues/7995): Update liner dependency to handle docker exec. +- [#7811](https://github.com/influxdata/influxdb/issues/7811): Kill query not killing query +- [#7457](https://github.com/influxdata/influxdb/issues/7457): KILL QUERY should work during all phases of a query ## v1.2.2 [2017-03-14] diff --git a/influxql/internal/internal.pb.go b/influxql/internal/internal.pb.go index 700a4706509..5c9d474dd61 100644 --- a/influxql/internal/internal.pb.go +++ b/influxql/internal/internal.pb.go @@ -505,51 +505,44 @@ func init() { func init() { proto.RegisterFile("internal/internal.proto", fileDescriptorInternal) } var fileDescriptorInternal = []byte{ - // 726 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x84, 0x54, 0x51, 0x6b, 0xe3, 0x46, - 0x10, 0x46, 0x92, 0xe5, 0x58, 0xeb, 0xb8, 0x49, 0xb7, 0x69, 0xb2, 0x94, 0xd2, 0x0a, 0x3d, 0x09, - 0x4a, 0x1d, 0xc8, 0x6b, 0xa1, 0xe0, 0x34, 0x49, 0x31, 0x5c, 0x9c, 0xb0, 0x0a, 0x79, 0xdf, 0x8b, - 0xc6, 0x62, 0x41, 0x5e, 0xf9, 0x56, 0xab, 0xc3, 0xf9, 0x29, 0xf7, 0x1b, 0xee, 0xc7, 0xdc, 0xcb, - 0xfd, 0xa0, 0x63, 0x67, 0x25, 0x4b, 0xc9, 0xc1, 0xe5, 0x49, 0xf3, 0x7d, 0x33, 0xbb, 0xab, 0x99, - 0xf9, 0x66, 0xc8, 0x99, 0x54, 0x06, 0xb4, 0x12, 0xe5, 0x79, 0x67, 0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7, 0x01, 0xfb, 0xde, 0xb2, 0x7e, - 0x10, 0xba, 0x00, 0xd3, 0xce, 0xcc, 0x1e, 0x27, 0xff, 0xf6, 0xd2, 0xc4, 0xff, 0x6a, 0xb4, 0x40, - 0x25, 0x78, 0x58, 0x9c, 0x3d, 0x1e, 0x34, 0xc7, 0x1f, 0x36, 0x27, 0x59, 0x90, 0xd9, 0x8b, 0xad, - 0x81, 0x5d, 0x69, 0x0b, 0xec, 0xb5, 0x5d, 0x69, 0xab, 0x7b, 0x4a, 0xc6, 0xb8, 0x99, 0x57, 0xdd, - 0x15, 0x0e, 0x25, 0x73, 0x32, 0x76, 0x03, 0x66, 0x87, 0xf2, 0x51, 0x94, 0xed, 0xc6, 0xb6, 0x26, - 0x2e, 0x67, 0xbb, 0x70, 0x7c, 0xa7, 0x67, 0x6b, 0x7f, 0x0b, 0x00, 0x00, 0xff, 0xff, 0xd1, 0x2a, - 0x83, 0x14, 0x06, 0x06, 0x00, 0x00, + // 609 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x53, 0xe1, 0x4e, 0xdb, 0x30, + 0x10, 0x56, 0xea, 0xa6, 0x4d, 0x2e, 0x2d, 0x6d, 0x0d, 0x13, 0xd6, 0x7e, 0x45, 0x1d, 0x42, 0xf9, + 0x31, 0xb1, 0x09, 0xed, 0x05, 0xca, 0x80, 0xa9, 0xd2, 0x28, 0x88, 0x20, 0xfe, 0x7b, 0xe4, 0x1a, + 0x59, 0x72, 0x9d, 0xce, 0x76, 0xa6, 0xf2, 0x38, 0x7b, 0xbe, 0xbd, 0xc4, 0x64, 0x37, 0xa1, 0x1d, + 0x42, 0xfb, 0x97, 0xfb, 0x7c, 0x77, 0xf9, 0xee, 0xfb, 0xee, 0xe0, 0x58, 0x28, 0x8b, 0x5a, 0x71, + 0xf9, 0xa9, 0xfd, 0x38, 0x5b, 0xeb, 0xca, 0x56, 0x34, 0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0x51, 0x9b, 0x70, 0x89, 0x45, 0xbd, 0x46, 0x36, 0xf6, 0xfd, 0x28, 0xc0, + 0x0d, 0xdf, 0xe4, 0xa8, 0x05, 0x9a, 0x05, 0xa3, 0x6d, 0xd1, 0xad, 0x2e, 0x50, 0x63, 0xc1, 0x8e, + 0xbc, 0x47, 0x5f, 0x60, 0xb0, 0xa7, 0x9c, 0xa1, 0x27, 0x10, 0xce, 0x2d, 0xae, 0x0c, 0x0b, 0xfe, + 0x23, 0xf0, 0xb4, 0x84, 0x64, 0x5f, 0xef, 0x66, 0x9f, 0x7e, 0x70, 0x83, 0x8d, 0xb1, 0xc7, 0x30, + 0xba, 0x47, 0x8b, 0xca, 0xa9, 0x72, 0x57, 0x49, 0xf1, 0xf4, 0xec, 0x97, 0x2a, 0x7e, 0xb9, 0x32, + 0xe2, 0xa3, 0x21, 0x84, 0xf7, 0x58, 0xe2, 0xa6, 0x59, 0xa3, 0x31, 0x44, 0x73, 0xf3, 0xc0, 0x75, + 0x89, 0xb6, 0x59, 0xa1, 0x8f, 0x3b, 0x27, 0xfd, 0x5f, 0x6a, 0xcd, 0xbd, 0xd0, 0xc1, 0x2b, 0x89, + 0x5c, 0x73, 0x32, 0xfd, 0x0c, 0xc3, 0x7f, 0xf6, 0xdd, 0x6b, 0xd4, 0xcc, 0xff, 0x52, 0xe1, 0xaf, + 0x7d, 0xd1, 0x54, 0x7c, 0x80, 0x5e, 0xb3, 0x5b, 0x09, 0x90, 0x47, 0x2e, 0xf7, 0xae, 0xdf, 0x1d, + 0x87, 0x4b, 0x0a, 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0xbc, 0x54, 0x7d, 0x69, 0x47, 0x04, 0x00, + 0x00, } diff --git a/influxql/iterator.gen.go b/influxql/iterator.gen.go index acf2a8a5926..03f0fc7cca5 100644 --- a/influxql/iterator.gen.go +++ b/influxql/iterator.gen.go @@ -767,7 +767,7 @@ func (itr *floatInterruptIterator) Next() (*FloatPoint, error) { if itr.count&0xFF == 0xFF { select { case <-itr.closing: - return nil, nil + return nil, itr.Close() default: // Reset iterator count to zero and fall through to emit the next point. itr.count = 0 @@ -3424,7 +3424,7 @@ func (itr *integerInterruptIterator) Next() (*IntegerPoint, error) { if itr.count&0xFF == 0xFF { select { case <-itr.closing: - return nil, nil + return nil, itr.Close() default: // Reset iterator count to zero and fall through to emit the next point. itr.count = 0 @@ -6064,7 +6064,7 @@ func (itr *stringInterruptIterator) Next() (*StringPoint, error) { if itr.count&0xFF == 0xFF { select { case <-itr.closing: - return nil, nil + return nil, itr.Close() default: // Reset iterator count to zero and fall through to emit the next point. itr.count = 0 @@ -8704,7 +8704,7 @@ func (itr *booleanInterruptIterator) Next() (*BooleanPoint, error) { if itr.count&0xFF == 0xFF { select { case <-itr.closing: - return nil, nil + return nil, itr.Close() default: // Reset iterator count to zero and fall through to emit the next point. itr.count = 0 diff --git a/influxql/iterator.gen.go.tmpl b/influxql/iterator.gen.go.tmpl index 08e39457f9f..d8040f5d89b 100644 --- a/influxql/iterator.gen.go.tmpl +++ b/influxql/iterator.gen.go.tmpl @@ -768,7 +768,7 @@ func (itr *{{$k.name}}InterruptIterator) Next() (*{{$k.Name}}Point, error) { if itr.count & 0xFF == 0xFF { select { case <-itr.closing: - return nil, nil + return nil, itr.Close() default: // Reset iterator count to zero and fall through to emit the next point. itr.count = 0 diff --git a/tsdb/engine/tsm1/engine.go b/tsdb/engine/tsm1/engine.go index 67eb5448acd..6e30940c2bc 100644 --- a/tsdb/engine/tsm1/engine.go +++ b/tsdb/engine/tsm1/engine.go @@ -1292,7 +1292,7 @@ func (e *Engine) createCallIterator(measurement string, call *influxql.Call, opt } // Determine tagsets for this measurement based on dimensions and filters. - tagSets, err := mm.TagSets(e.id, opt.Dimensions, opt.Condition) + tagSets, err := mm.TagSets(e.id, opt) if err != nil { return nil, err } @@ -1310,6 +1310,14 @@ func (e *Engine) createCallIterator(measurement string, call *influxql.Call, opt itrs := make([]influxql.Iterator, 0, len(tagSets)) if err := func() error { for _, t := range tagSets { + // Abort if the query was killed + select { + case <-opt.InterruptCh: + influxql.Iterators(itrs).Close() + return err + default: + } + inputs, err := e.createTagSetIterators(ref, mm, t, opt) if err != nil { return err @@ -1352,7 +1360,7 @@ func (e *Engine) createVarRefIterator(measurement string, opt influxql.IteratorO } // Determine tagsets for this measurement based on dimensions and filters. - tagSets, err := mm.TagSets(e.id, opt.Dimensions, opt.Condition) + tagSets, err := mm.TagSets(e.id, opt) if err != nil { return nil, err } @@ -1509,6 +1517,21 @@ func (e *Engine) createTagSetGroupIterators(ref *influxql.VarRef, mm *tsdb.Measu continue } itrs = append(itrs, itr) + + // Abort if the query was killed + select { + case <-opt.InterruptCh: + influxql.Iterators(itrs).Close() + return nil, err + default: + } + + // Enforce series limit at creation time. + if opt.MaxSeriesN > 0 && len(itrs) > opt.MaxSeriesN { + influxql.Iterators(itrs).Close() + return nil, fmt.Errorf("max-select-series limit exceeded: (%d/%d)", len(itrs), opt.MaxSeriesN) + } + } return itrs, nil } diff --git a/tsdb/meta.go b/tsdb/meta.go index 7d3922e28c9..c57f774fc3d 100644 --- a/tsdb/meta.go +++ b/tsdb/meta.go @@ -793,11 +793,11 @@ func (m *Measurement) filters(condition influxql.Expr) ([]uint64, map[uint64]inf // This will also populate the TagSet objects with the series IDs that match each tagset and any // influx filter expression that goes with the series // TODO: this shouldn't be exported. However, until tx.go and the engine get refactored into tsdb, we need it. -func (m *Measurement) TagSets(shardID uint64, dimensions []string, condition influxql.Expr) ([]*influxql.TagSet, error) { +func (m *Measurement) TagSets(shardID uint64, opt influxql.IteratorOptions) ([]*influxql.TagSet, error) { m.mu.RLock() // get the unique set of series ids and the filters that should be applied to each - ids, filters, err := m.filters(condition) + ids, filters, err := m.filters(opt.Condition) if err != nil { m.mu.RUnlock() return nil, err @@ -807,15 +807,27 @@ func (m *Measurement) TagSets(shardID uint64, dimensions []string, condition inf // TagSet for that series. Series with the same TagSet are then grouped together, because for the // purpose of GROUP BY they are part of the same composite series. tagSets := make(map[string]*influxql.TagSet, 64) + var seriesN int for _, id := range ids { + // Abort if the query was killed + select { + case <-opt.InterruptCh: + return nil, influxql.ErrQueryInterrupted + default: + } + + if opt.MaxSeriesN > 0 && seriesN > opt.MaxSeriesN { + return nil, fmt.Errorf("max-select-series limit exceeded: (%d/%d)", seriesN, opt.MaxSeriesN) + } + s := m.seriesByID[id] if !s.Assigned(shardID) { continue } - tags := make(map[string]string, len(dimensions)) + tags := make(map[string]string, len(opt.Dimensions)) // Build the TagSet for this series. - for _, dim := range dimensions { + for _, dim := range opt.Dimensions { tags[dim] = s.GetTagString(dim) } @@ -832,6 +844,7 @@ func (m *Measurement) TagSets(shardID uint64, dimensions []string, condition inf } // Associate the series and filter with the Tagset. tagSet.AddFilter(m.seriesByID[id].Key, filters[id]) + seriesN++ // Ensure it's back in the map. tagSets[string(tagsAsKey)] = tagSet @@ -841,6 +854,13 @@ func (m *Measurement) TagSets(shardID uint64, dimensions []string, condition inf // Sort the series in each tag set. for _, t := range tagSets { + // Abort if the query was killed + select { + case <-opt.InterruptCh: + return nil, influxql.ErrQueryInterrupted + default: + } + sort.Sort(t) } diff --git a/tsdb/shard.go b/tsdb/shard.go index f9e7b3c7d05..8cbde52aec8 100644 --- a/tsdb/shard.go +++ b/tsdb/shard.go @@ -1046,6 +1046,13 @@ func (a Shards) CreateIterator(measurement string, opt influxql.IteratorOptions) } itrs = append(itrs, itr) + select { + case <-opt.InterruptCh: + influxql.Iterators(itrs).Close() + return nil, err + default: + } + // Enforce series limit at creation time. if opt.MaxSeriesN > 0 { stats := itr.Stats()