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

workload: tolerate ambiguous commit errors with --tolerate-ambiguous-errors #52555

Closed
wants to merge 1 commit into from
Closed
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
13 changes: 12 additions & 1 deletion pkg/workload/cli/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"sync/atomic"
"time"

"github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgcode"
"github.com/cockroachdb/cockroach/pkg/util/envutil"
"github.com/cockroachdb/cockroach/pkg/util/log"
"github.com/cockroachdb/cockroach/pkg/util/log/logflags"
Expand All @@ -35,13 +36,16 @@ import (
"github.com/cockroachdb/cockroach/pkg/workload/histogram"
"github.com/cockroachdb/cockroach/pkg/workload/workloadsql"
"github.com/cockroachdb/errors"
"github.com/jackc/pgx"
"github.com/lib/pq"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"golang.org/x/time/rate"
)

var runFlags = pflag.NewFlagSet(`run`, pflag.ContinueOnError)
var tolerateErrors = runFlags.Bool("tolerate-errors", false, "Keep running on error")
var tolerateAmbiguousErrors = runFlags.Bool("tolerate-ambiguous-errors", false, "Keep running on ambiguous commit errors")
var maxRate = runFlags.Float64(
"max-rate", 0, "Maximum frequency of operations (reads/writes). If 0, no limit.")
var maxOps = runFlags.Uint64("max-ops", 0, "Maximum number of operations to run")
Expand Down Expand Up @@ -464,7 +468,14 @@ func runRun(gen workload.Generator, urls []string, dbName string) error {
select {
case err := <-errCh:
formatter.outputError(err)
if *tolerateErrors {
ignoreErr := *tolerateErrors
if pqErr := (*pq.Error)(nil); errors.As(err, &pqErr) && string(pqErr.Code) == pgcode.StatementCompletionUnknown.String() {
ignoreErr = ignoreErr || *tolerateAmbiguousErrors
}
if pgxErr := (*pgx.PgError)(nil); errors.As(err, &pgxErr) && pgxErr.Code == pgcode.StatementCompletionUnknown.String() {
ignoreErr = ignoreErr || *tolerateAmbiguousErrors
}
if ignoreErr {
if everySecond.ShouldLog() {
log.Errorf(ctx, "%v", err)
}
Expand Down