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

release-22.1: spanconfig: reset job run_stats to avoid job system backoff #82858

Merged
merged 1 commit into from
Jun 14, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pkg/spanconfig/spanconfigjob/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ go_library(
deps = [
"//pkg/jobs",
"//pkg/jobs/jobspb",
"//pkg/kv",
"//pkg/settings",
"//pkg/settings/cluster",
"//pkg/spanconfig",
Expand Down
16 changes: 16 additions & 0 deletions pkg/spanconfig/spanconfigjob/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (

"github.com/cockroachdb/cockroach/pkg/jobs"
"github.com/cockroachdb/cockroach/pkg/jobs/jobspb"
"github.com/cockroachdb/cockroach/pkg/kv"
"github.com/cockroachdb/cockroach/pkg/settings"
"github.com/cockroachdb/cockroach/pkg/settings/cluster"
"github.com/cockroachdb/cockroach/pkg/spanconfig"
Expand Down Expand Up @@ -75,6 +76,21 @@ func (r *resumer) Resume(ctx context.Context, execCtxI interface{}) (jobErr erro
// indicate through the job's idle status.
r.job.MarkIdle(true)

// If the Job's NumRuns is greater than 1, reset it to 0 so that future
// resumptions are not delayed by the job system.
//
// Note that we are doing this before the possible error return below. If
// there is a problem starting the reconciler this job will aggressively
// restart at the job system level with no backoff.
if err := r.job.Update(ctx, nil, func(_ *kv.Txn, md jobs.JobMetadata, ju *jobs.JobUpdater) error {
if md.RunStats != nil && md.RunStats.NumRuns > 1 {
ju.UpdateRunStats(1, md.RunStats.LastRun)
}
return nil
}); err != nil {
log.Warningf(ctx, "failed to reset reconciliation job run stats: %v", err)
}

// Start the protected timestamp reconciler. This will periodically poll the
// protected timestamp table to cleanup stale records. We take advantage of
// the fact that there can only be one instance of the spanconfig.Resumer
Expand Down