Skip to content

Commit

Permalink
Merge #36048 #36171
Browse files Browse the repository at this point in the history
36048: workload: add new mode for querylog to generate querybench-like file r=yuzefovich a=yuzefovich

Adds a new mode for querylog workload to write the generated
queries into a file that querybench understands. Also, some fixes
of querylog itself.

Release note: None

36171: roachtest: print when index rollback job has completed r=vivekmenezes a=vivekmenezes

Release note: None

Co-authored-by: Yahor Yuzefovich <[email protected]>
Co-authored-by: Vivek Menezes <[email protected]>
  • Loading branch information
3 people committed Mar 26, 2019
3 parents 40f6248 + 95b14c5 + 878d093 commit 15913f5
Show file tree
Hide file tree
Showing 3 changed files with 247 additions and 52 deletions.
6 changes: 5 additions & 1 deletion pkg/cmd/roachtest/schemachange.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,11 @@ func makeIndexAddRollbackTpccTest(numNodes, warehouses int, length time.Duration

backoff := 30 * time.Second
retryOpts = retry.Options{InitialBackoff: backoff, MaxBackoff: backoff, Multiplier: 1, MaxRetries: int(length / backoff)}
return jobutils.WaitForStatus(ctx, conn, rollbackID, jobs.StatusSucceeded, retryOpts)
if err := jobutils.WaitForStatus(ctx, conn, rollbackID, jobs.StatusSucceeded, retryOpts); err != nil {
return err
}
c.l.Printf("%s: rollback %d complete\n", prefix, rollbackID)
return nil
},
Duration: length,
})
Expand Down
18 changes: 14 additions & 4 deletions pkg/workload/querybench/query_bench.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type queryBench struct {
connFlags *workload.ConnFlags
queryFile string
useOpt bool
verbose bool

queries []string
}
Expand All @@ -56,6 +57,7 @@ var queryBenchMeta = workload.Meta{
}
g.flags.StringVar(&g.queryFile, `query-file`, ``, `File of newline separated queries to run`)
g.flags.BoolVar(&g.useOpt, `use-opt`, true, `Use cost-based optimizer`)
g.flags.BoolVar(&g.verbose, `verbose`, true, `Prints out the queries being run as well as histograms`)
g.connFlags = workload.NewConnFlags(&g.flags)
return g
},
Expand Down Expand Up @@ -131,9 +133,10 @@ func (g *queryBench) Ops(urls []string, reg *histogram.Registry) (workload.Query
ql := workload.QueryLoad{SQLDatabase: sqlDatabase}
for i := 0; i < g.connFlags.Concurrency; i++ {
op := queryBenchWorker{
hists: reg.GetHandle(),
db: db,
stmts: stmts,
hists: reg.GetHandle(),
db: db,
stmts: stmts,
verbose: g.verbose,
}
ql.WorkerFns = append(ql.WorkerFns, op.run)
}
Expand All @@ -150,6 +153,8 @@ func getQueries(path string) ([]string, error) {
defer file.Close()

scanner := bufio.NewScanner(file)
// Read lines up to 1 MB in size.
scanner.Buffer(make([]byte, 64*1024), 1024*1024)
var lines []string
for scanner.Scan() {
line := scanner.Text()
Expand All @@ -174,6 +179,7 @@ type queryBenchWorker struct {
stmts []namedStmt

stmtIdx int
verbose bool
}

func (o *queryBenchWorker) run(ctx context.Context) error {
Expand All @@ -193,6 +199,10 @@ func (o *queryBenchWorker) run(ctx context.Context) error {
return err
}
elapsed := timeutil.Since(start)
o.hists.Get(stmt.name).Record(elapsed)
if o.verbose {
o.hists.Get(stmt.name).Record(elapsed)
} else {
o.hists.Get("").Record(elapsed)
}
return nil
}
Loading

0 comments on commit 15913f5

Please sign in to comment.