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

[dbnode/query] Optionally error if query exceeds series limit via RequireExhaustive config #2400

Merged
merged 25 commits into from
Jun 11, 2020
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
f00fc1f
err in case of limit exceeded 1
rallen090 Jun 9, 2020
51abb38
err in case of limit exceeded 2
rallen090 Jun 9, 2020
577f0ee
err in case of limit exceeded 3
rallen090 Jun 9, 2020
e14be6c
err in case of limit exceeded 4
rallen090 Jun 9, 2020
cb6f587
require exhaustive error test cases
rallen090 Jun 9, 2020
9fc7056
Merge remote-tracking branch 'origin/master' into ra/err-query-over-l…
rallen090 Jun 9, 2020
108e7a4
require exhaustive error test cases 2
rallen090 Jun 9, 2020
f9545bb
Merge remote-tracking branch 'origin/master' into ra/err-query-over-l…
rallen090 Jun 9, 2020
130c1af
Merge remote-tracking branch 'origin/master' into ra/err-query-over-l…
rallen090 Jun 10, 2020
3ea215b
test cases for allowing non-exhaustive 1
rallen090 Jun 10, 2020
e689811
test cases for allowing non-exhaustive 2
rallen090 Jun 10, 2020
ebf1f51
test cases for allowing non-exhaustive 3
rallen090 Jun 10, 2020
29d1ae8
test cases for allowing non-exhaustive 4
rallen090 Jun 10, 2020
6c117b6
Merge remote-tracking branch 'origin/master' into ra/err-query-over-l…
rallen090 Jun 10, 2020
596759c
test cases for allowing non-exhaustive 5
rallen090 Jun 11, 2020
34cbaef
dbnode mock gen
rallen090 Jun 11, 2020
39475d0
Merge remote-tracking branch 'origin/master' into ra/err-query-over-l…
rallen090 Jun 11, 2020
4a65615
more exhaustive query metrics
rallen090 Jun 11, 2020
6dbbee8
Merge remote-tracking branch 'origin/master' into ra/err-query-over-l…
rallen090 Jun 11, 2020
c518cbb
reverting cost mock gen in query
rallen090 Jun 11, 2020
ec8aafd
mod fix
rallen090 Jun 11, 2020
a818509
mod fix 2
rallen090 Jun 11, 2020
d116b5d
mod fix 3
rallen090 Jun 11, 2020
9a1473e
rpc mock
rallen090 Jun 11, 2020
c82fa90
mod fix 5
rallen090 Jun 11, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/cmd/services/m3query/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,9 @@ type PerQueryLimitsConfiguration struct {

// MaxFetchedSeries limits the number of time series returned by a storage node.
MaxFetchedSeries int `yaml:"maxFetchedSeries"`

// RequireExhaustive results in an error if the query exceeds the series limit.
RequireExhaustive bool `yaml:"requireExhaustive"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: I think something like FailOnLimitExceeded is a bit more descriptive here?

}

// AsLimitManagerOptions converts this configuration to
Expand All @@ -306,12 +309,14 @@ func (l *PerQueryLimitsConfiguration) AsLimitManagerOptions() cost.LimitManagerO
func (l *PerQueryLimitsConfiguration) AsFetchOptionsBuilderOptions() handleroptions.FetchOptionsBuilderOptions {
if l.MaxFetchedSeries <= 0 {
return handleroptions.FetchOptionsBuilderOptions{
Limit: defaultStorageQueryLimit,
Limit: defaultStorageQueryLimit,
RequireExhaustive: l.RequireExhaustive,
}
}

return handleroptions.FetchOptionsBuilderOptions{
Limit: int(l.MaxFetchedSeries),
Limit: int(l.MaxFetchedSeries),
RequireExhaustive: l.RequireExhaustive,
}
}

Expand Down
1 change: 1 addition & 0 deletions src/dbnode/generated/thrift/rpc.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ struct FetchTaggedRequest {
5: required bool fetchData
6: optional i64 limit
7: optional TimeType rangeTimeType = TimeType.UNIX_SECONDS
8: optional bool requireExhaustive = false
}

struct FetchTaggedResult {
Expand Down
57 changes: 50 additions & 7 deletions src/dbnode/generated/thrift/rpc/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -3049,14 +3049,16 @@ func (p *Segment) String() string {
// - FetchData
// - Limit
// - RangeTimeType
// - RequireExhaustive
type FetchTaggedRequest struct {
NameSpace []byte `thrift:"nameSpace,1,required" db:"nameSpace" json:"nameSpace"`
Query []byte `thrift:"query,2,required" db:"query" json:"query"`
RangeStart int64 `thrift:"rangeStart,3,required" db:"rangeStart" json:"rangeStart"`
RangeEnd int64 `thrift:"rangeEnd,4,required" db:"rangeEnd" json:"rangeEnd"`
FetchData bool `thrift:"fetchData,5,required" db:"fetchData" json:"fetchData"`
Limit *int64 `thrift:"limit,6" db:"limit" json:"limit,omitempty"`
RangeTimeType TimeType `thrift:"rangeTimeType,7" db:"rangeTimeType" json:"rangeTimeType,omitempty"`
NameSpace []byte `thrift:"nameSpace,1,required" db:"nameSpace" json:"nameSpace"`
Query []byte `thrift:"query,2,required" db:"query" json:"query"`
RangeStart int64 `thrift:"rangeStart,3,required" db:"rangeStart" json:"rangeStart"`
RangeEnd int64 `thrift:"rangeEnd,4,required" db:"rangeEnd" json:"rangeEnd"`
FetchData bool `thrift:"fetchData,5,required" db:"fetchData" json:"fetchData"`
Limit *int64 `thrift:"limit,6" db:"limit" json:"limit,omitempty"`
RangeTimeType TimeType `thrift:"rangeTimeType,7" db:"rangeTimeType" json:"rangeTimeType,omitempty"`
RequireExhaustive bool `thrift:"requireExhaustive,8" db:"requireExhaustive" json:"requireExhaustive,omitempty"`
}

func NewFetchTaggedRequest() *FetchTaggedRequest {
Expand Down Expand Up @@ -3099,6 +3101,12 @@ var FetchTaggedRequest_RangeTimeType_DEFAULT TimeType = 0
func (p *FetchTaggedRequest) GetRangeTimeType() TimeType {
return p.RangeTimeType
}

var FetchTaggedRequest_RequireExhaustive_DEFAULT bool = false

func (p *FetchTaggedRequest) GetRequireExhaustive() bool {
return p.RequireExhaustive
}
func (p *FetchTaggedRequest) IsSetLimit() bool {
return p.Limit != nil
}
Expand All @@ -3107,6 +3115,10 @@ func (p *FetchTaggedRequest) IsSetRangeTimeType() bool {
return p.RangeTimeType != FetchTaggedRequest_RangeTimeType_DEFAULT
}

func (p *FetchTaggedRequest) IsSetRequireExhaustive() bool {
return p.RequireExhaustive != FetchTaggedRequest_RequireExhaustive_DEFAULT
}

func (p *FetchTaggedRequest) Read(iprot thrift.TProtocol) error {
if _, err := iprot.ReadStructBegin(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
Expand Down Expand Up @@ -3160,6 +3172,10 @@ func (p *FetchTaggedRequest) Read(iprot thrift.TProtocol) error {
if err := p.ReadField7(iprot); err != nil {
return err
}
case 8:
if err := p.ReadField8(iprot); err != nil {
return err
}
default:
if err := iprot.Skip(fieldTypeId); err != nil {
return err
Expand Down Expand Up @@ -3254,6 +3270,15 @@ func (p *FetchTaggedRequest) ReadField7(iprot thrift.TProtocol) error {
return nil
}

func (p *FetchTaggedRequest) ReadField8(iprot thrift.TProtocol) error {
if v, err := iprot.ReadBool(); err != nil {
return thrift.PrependError("error reading field 8: ", err)
} else {
p.RequireExhaustive = v
}
return nil
}

func (p *FetchTaggedRequest) Write(oprot thrift.TProtocol) error {
if err := oprot.WriteStructBegin("FetchTaggedRequest"); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err)
Expand All @@ -3280,6 +3305,9 @@ func (p *FetchTaggedRequest) Write(oprot thrift.TProtocol) error {
if err := p.writeField7(oprot); err != nil {
return err
}
if err := p.writeField8(oprot); err != nil {
return err
}
}
if err := oprot.WriteFieldStop(); err != nil {
return thrift.PrependError("write field stop error: ", err)
Expand Down Expand Up @@ -3385,6 +3413,21 @@ func (p *FetchTaggedRequest) writeField7(oprot thrift.TProtocol) (err error) {
return err
}

func (p *FetchTaggedRequest) writeField8(oprot thrift.TProtocol) (err error) {
if p.IsSetRequireExhaustive() {
if err := oprot.WriteFieldBegin("requireExhaustive", thrift.BOOL, 8); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 8:requireExhaustive: ", p), err)
}
if err := oprot.WriteBool(bool(p.RequireExhaustive)); err != nil {
return thrift.PrependError(fmt.Sprintf("%T.requireExhaustive (8) field write error: ", p), err)
}
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 8:requireExhaustive: ", p), err)
}
}
return err
}

func (p *FetchTaggedRequest) String() string {
if p == nil {
return "<nil>"
Expand Down
Loading