Skip to content

Commit

Permalink
test(launcher): e2e test memory limits
Browse files Browse the repository at this point in the history
  • Loading branch information
affo committed Apr 1, 2020
1 parent 5915fd3 commit e59a91a
Show file tree
Hide file tree
Showing 6 changed files with 450 additions and 54 deletions.
58 changes: 44 additions & 14 deletions cmd/influxd/launcher/launcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"errors"
"fmt"
"io"
"math"
"net"
nethttp "net/http"
_ "net/http/pprof" // needed to add pprof to our binary.
Expand Down Expand Up @@ -279,6 +278,36 @@ func buildLauncherCommand(l *Launcher, cmd *cobra.Command) {
Default: false,
Desc: "disables the task scheduler",
},
{
DestP: &l.concurrencyQuota,
Flag: "query-concurrency",
Default: 10,
Desc: "the number of queries that are allowed to execute concurrently",
},
{
DestP: &l.initialMemoryBytesQuotaPerQuery,
Flag: "query-initial-memory-bytes",
Default: 0,
Desc: "the initial number of bytes allocated for a query when it is started. If this is unset, then query-memory-bytes will be used",
},
{
DestP: &l.memoryBytesQuotaPerQuery,
Flag: "query-memory-bytes",
Default: 10 * 1024 * 1024, // 10MB
Desc: "maximum number of bytes a query is allowed to use at any given time. This must be greater or equal to query-initial-memory-bytes",
},
{
DestP: &l.maxMemoryBytes,
Flag: "query-max-memory-bytes",
Default: 0,
Desc: "the maximum amount of memory used for queries. If this is unset, then this number is query-concurrency * query-memory-bytes",
},
{
DestP: &l.queueSize,
Flag: "query-queue-size",
Default: 10,
Desc: "the number of queries that are allowed to be awaiting execution before new queries are rejected",
},
}

cli.BindOptions(cmd, opts)
Expand Down Expand Up @@ -309,6 +338,13 @@ type Launcher struct {
enableNewMetaStore bool
newMetaStoreReadOnly bool

// Query options.
concurrencyQuota int
initialMemoryBytesQuotaPerQuery int
memoryBytesQuotaPerQuery int
maxMemoryBytes int
queueSize int

boltClient *bolt.Client
kvStore kv.Store
kvService *kv.Service
Expand Down Expand Up @@ -642,14 +678,6 @@ func (m *Launcher) run(ctx context.Context) (err error) {
backupService platform.BackupService = m.engine
)

// TODO(cwolff): Figure out a good default per-query memory limit:
// https://github.com/influxdata/influxdb/issues/13642
const (
concurrencyQuota = 10
memoryBytesQuotaPerQuery = math.MaxInt64
QueueSize = 10
)

deps, err := influxdb.NewDependencies(
storageflux.NewReader(readservice.NewStore(m.engine)),
m.engine,
Expand All @@ -664,11 +692,13 @@ func (m *Launcher) run(ctx context.Context) (err error) {
}

m.queryController, err = control.New(control.Config{
ConcurrencyQuota: concurrencyQuota,
MemoryBytesQuotaPerQuery: int64(memoryBytesQuotaPerQuery),
QueueSize: QueueSize,
Logger: m.log.With(zap.String("service", "storage-reads")),
ExecutorDependencies: []flux.Dependency{deps},
ConcurrencyQuota: m.concurrencyQuota,
InitialMemoryBytesQuotaPerQuery: int64(m.initialMemoryBytesQuotaPerQuery),
MemoryBytesQuotaPerQuery: int64(m.memoryBytesQuotaPerQuery),
MaxMemoryBytes: int64(m.maxMemoryBytes),
QueueSize: m.queueSize,
Logger: m.log.With(zap.String("service", "storage-reads")),
ExecutorDependencies: []flux.Dependency{deps},
})
if err != nil {
m.log.Error("Failed to create query controller", zap.Error(err))
Expand Down
11 changes: 10 additions & 1 deletion cmd/influxd/launcher/launcher_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,16 @@ func (tl *TestLauncher) Run(ctx context.Context, args ...string) error {
args = append(args, "--bolt-path", filepath.Join(tl.Path, bolt.DefaultFilename))
args = append(args, "--engine-path", filepath.Join(tl.Path, "engine"))
args = append(args, "--http-bind-address", "127.0.0.1:0")
args = append(args, "--log-level", "debug")
logLevel := false
for _, arg := range args {
if arg == "--log-level" {
logLevel = true
break
}
}
if !logLevel {
args = append(args, "--log-level", "debug")
}
return tl.Launcher.Run(ctx, args...)
}

Expand Down
Loading

0 comments on commit e59a91a

Please sign in to comment.