Skip to content
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
5 changes: 5 additions & 0 deletions pkg/jobs/adopt.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ func (r *Registry) maybeDumpTrace(resumerCtx context.Context, resumer Resumer, j
// claimJobs places a claim with the given SessionID to job rows that are
// available.
func (r *Registry) claimJobs(ctx context.Context, s sqlliveness.Session) error {

timeout := claimQueryTimeout.Get(&r.settings.SV)
ctx, cancel := context.WithDeadlineCause(ctx, timeutil.Now().Add(timeout), errors.New("claim jobs transaction took too long"))
defer cancel()

return r.db.Txn(ctx, func(ctx context.Context, txn isql.Txn) error {
// Run the claim transaction at low priority to ensure that it does not
// contend with foreground reads.
Expand Down
9 changes: 9 additions & 0 deletions pkg/jobs/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const (
cancelUpdateLimitKey = "jobs.cancel_update_limit"
debugPausePointsSettingKey = "jobs.debug.pausepoints"
metricsPollingIntervalKey = "jobs.metrics.interval.poll"
claimQueryTimeoutKey = "jobs.registry.claim_query.timeout"
)

const (
Expand Down Expand Up @@ -134,6 +135,14 @@ var (
"the list, comma separated, of named pausepoints currently enabled for debugging",
"",
)

claimQueryTimeout = settings.RegisterDurationSetting(
settings.ApplicationLevel,
claimQueryTimeoutKey,
"the timeout for the claim query used when adopting jobs",
time.Minute,
settings.PositiveDuration,
)
)

// jitter adds a small jitter in the given duration.
Expand Down