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

jobs: tiny improvement to error handling #57307

Merged
merged 1 commit into from Dec 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion pkg/jobs/BUILD.bazel
Expand Up @@ -46,7 +46,6 @@ go_library(
"//pkg/util/envutil",
"//pkg/util/hlc",
"//pkg/util/log",
"//pkg/util/log/logcrash",
"//pkg/util/metric",
"//pkg/util/protoutil",
"//pkg/util/retry",
Expand Down
15 changes: 3 additions & 12 deletions pkg/jobs/adopt.go
Expand Up @@ -21,7 +21,6 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql/sessiondata"
"github.com/cockroachdb/cockroach/pkg/sql/sqlliveness"
"github.com/cockroachdb/cockroach/pkg/util/log"
"github.com/cockroachdb/cockroach/pkg/util/log/logcrash"
"github.com/cockroachdb/cockroach/pkg/util/tracing"
"github.com/cockroachdb/errors"
)
Expand Down Expand Up @@ -253,15 +252,6 @@ func (r *Registry) runJob(
// Run the actual job.
err := r.stepThroughStateMachine(ctx, execCtx, resumer, resultsCh, job, status, finalResumeError)
if err != nil {
// TODO (lucy): This needs to distinguish between assertion errors in
// the job registry and assertion errors in job execution returned from
// Resume() or OnFailOrCancel(), and only fail on the former. We have
// tests that purposely introduce bad state in order to produce
// assertion errors, which shouldn't cause the test to panic. For now,
// comment this out.
// if errors.HasAssertionFailure(err) {
// logcrash.ReportOrPanic(ctx, nil, err.Error())
// }
log.Errorf(ctx, "job %d: adoption completed with error %v", *job.ID(), err)
}
r.unregister(*job.ID())
Expand Down Expand Up @@ -291,7 +281,8 @@ RETURNING id, status`,
for _, row := range rows {
id := int64(*row[0].(*tree.DInt))
job := &Job{id: &id, registry: r}
switch Status(*row[1].(*tree.DString)) {
statusString := *row[1].(*tree.DString)
switch Status(statusString) {
case StatusPaused:
r.unregister(id)
log.Infof(ctx, "job %d, session %s: paused", id, s.ID())
Expand All @@ -309,7 +300,7 @@ RETURNING id, status`,
log.Infof(ctx, "job %d, session id: %s canceled: the job is now reverting",
id, s.ID())
default:
logcrash.ReportOrPanic(ctx, nil, "unexpected job status")
return errors.AssertionFailedf("unexpected job status %s: %v", statusString, job)
}
}
return nil
Expand Down
9 changes: 0 additions & 9 deletions pkg/jobs/deprecated.go
Expand Up @@ -368,15 +368,6 @@ func (r *Registry) deprecatedResume(
}
err = r.stepThroughStateMachine(ctx, execCtx, resumer, resultsCh, job, status, finalResumeError)
if err != nil {
// TODO (lucy): This needs to distinguish between assertion errors in
// the job registry and assertion errors in job execution returned from
// Resume() or OnFailOrCancel(), and only fail on the former. We have
// tests that purposely introduce bad state in order to produce
// assertion errors, which shouldn't cause the test to panic. For now,
// comment this out.
// if errors.HasAssertionFailure(err) {
// logcrash.ReportOrPanic(ctx, nil, err.Error())
// }
log.Errorf(ctx, "job %d: adoption completed with error %v", *job.ID(), err)
}
status, err := job.CurrentStatus(ctx)
Expand Down