Skip to content
Merged
Changes from all commits
Commits
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
workload: use the same ctx for ramp and main load
We have seen issues where a worker returns ErrBadConn immediately after
the ramp period is done. It comes down to the fact that connections in
the pool are makred as "bad" when a context is canceled.

The underlying issue might be a race condition in how lib/pq cancels the
context and then marks the connection as "bad." But I'm not really sure
how to fix that and it's hard to reproduce, so I'm working around the
problem instead.

Release note: None
  • Loading branch information
rafiss committed Sep 30, 2021
commit a3ff7d5c95bb4950ce8a0dd5711fd2d09b0794bc
5 changes: 1 addition & 4 deletions pkg/workload/cli/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -464,14 +464,11 @@ func runRun(gen workload.Generator, urls []string, dbName string) error {
for i, workFn := range ops.WorkerFns {
go func(i int, workFn func(context.Context) error) {
// If a ramp period was specified, start all of the workers
// gradually with a new context.
// gradually.
if rampCtx != nil {
rampPerWorker := *ramp / time.Duration(len(ops.WorkerFns))
time.Sleep(time.Duration(i) * rampPerWorker)
workerRun(rampCtx, errCh, nil /* wg */, limiter, workFn)
}

// Start worker again, this time with the main context.
workerRun(workersCtx, errCh, &wg, limiter, workFn)
}(i, workFn)
}
Expand Down