Skip to content

Commit

Permalink
[dbnode] query limits - missed commit with feedback (#2640)
Browse files Browse the repository at this point in the history
  • Loading branch information
rallen090 authored Sep 16, 2020
1 parent b71785e commit 705f4f0
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/dbnode/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ func Run(runOpts RunOptions) {
bytesReadLimit.Limit = limitConfig.Value
bytesReadLimit.Lookback = limitConfig.Lookback
}
queryLimits, err := limits.NewQueryLimits(iopts, docsLimit, bytesReadLimit)
queryLimits, err := limits.NewQueryLimits(docsLimit, bytesReadLimit, iopts)
if err != nil {
logger.Fatal("could not construct docs query limits from config", zap.Error(err))
}
Expand Down
17 changes: 0 additions & 17 deletions src/dbnode/storage/limits/noop_query_limits.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,3 @@ func (q *noOpQueryLimits) Start() {
func (q *noOpLookbackLimit) Inc(int) error {
return nil
}

func (q *noOpLookbackLimit) Exceeded() error {
return nil
}

func (q *noOpLookbackLimit) Stop() {
}

func (q *noOpLookbackLimit) Start() {
}

func (q *noOpLookbackLimit) current() int64 {
return 0
}

func (q *noOpLookbackLimit) reset() {
}
8 changes: 3 additions & 5 deletions src/dbnode/storage/limits/query_limits.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"time"

"github.com/m3db/m3/src/x/instrument"

"github.com/uber-go/tally"
"go.uber.org/atomic"
)
Expand Down Expand Up @@ -67,9 +68,9 @@ func DefaultLookbackLimitOptions() LookbackLimitOptions {

// NewQueryLimits returns a new query limits manager.
func NewQueryLimits(
instrumentOpts instrument.Options,
docsLimitOpts LookbackLimitOptions,
bytesReadLimitOpts LookbackLimitOptions,
instrumentOpts instrument.Options,
) (QueryLimits, error) {
if err := docsLimitOpts.validate(); err != nil {
return nil, err
Expand Down Expand Up @@ -133,10 +134,7 @@ func (q *queryLimits) AnyExceeded() error {
if err := q.docsLimit.exceeded(); err != nil {
return err
}
if err := q.bytesReadLimit.exceeded(); err != nil {
return err
}
return nil
return q.bytesReadLimit.exceeded()
}

// Inc increments the current value and returns an error if above the limit.
Expand Down
4 changes: 2 additions & 2 deletions src/dbnode/storage/limits/query_limits_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestQueryLimits(t *testing.T) {
Limit: 1,
Lookback: time.Second,
}
queryLimits, err := NewQueryLimits(instrument.NewOptions(), docOpts, bytesOpts)
queryLimits, err := NewQueryLimits(docOpts, bytesOpts, instrument.NewOptions())
require.NoError(t, err)
require.NotNil(t, queryLimits)

Expand All @@ -53,7 +53,7 @@ func TestQueryLimits(t *testing.T) {
queryLimits.DocsLimit().Inc(2)
require.Error(t, queryLimits.AnyExceeded())

queryLimits, err = NewQueryLimits(instrument.NewOptions(), docOpts, bytesOpts)
queryLimits, err = NewQueryLimits(docOpts, bytesOpts, instrument.NewOptions())
require.NoError(t, err)
require.NotNil(t, queryLimits)

Expand Down
2 changes: 1 addition & 1 deletion src/dbnode/storage/limits/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
type QueryLimits interface {
// DocsLimit limits queries by a global concurrent count of index docs matched.
DocsLimit() LookbackLimit
// DocsLimit limits queries by a global concurrent count of bytes read from disk.
// BytesReadLimit limits queries by a global concurrent count of bytes read from disk.
BytesReadLimit() LookbackLimit

// AnyExceeded returns an error if any of the query limits are exceeded.
Expand Down

0 comments on commit 705f4f0

Please sign in to comment.