Skip to content

Commit b1435a9

Browse files
authored
Merge f36dc98 into blathers/backport-release-25.4-160084
2 parents 59976d5 + f36dc98 commit b1435a9

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

pkg/jobs/adopt.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ func (r *Registry) maybeDumpTrace(resumerCtx context.Context, resumer Resumer, j
9292
// claimJobs places a claim with the given SessionID to job rows that are
9393
// available.
9494
func (r *Registry) claimJobs(ctx context.Context, s sqlliveness.Session) error {
95+
96+
timeout := claimQueryTimeout.Get(&r.settings.SV)
97+
ctx, cancel := context.WithDeadlineCause(ctx, timeutil.Now().Add(timeout), errors.New("claim jobs transaction took too long"))
98+
defer cancel()
99+
95100
return r.db.Txn(ctx, func(ctx context.Context, txn isql.Txn) error {
96101
// Run the claim transaction at low priority to ensure that it does not
97102
// contend with foreground reads.

pkg/jobs/config.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const (
2424
cancelUpdateLimitKey = "jobs.cancel_update_limit"
2525
debugPausePointsSettingKey = "jobs.debug.pausepoints"
2626
metricsPollingIntervalKey = "jobs.metrics.interval.poll"
27+
claimQueryTimeoutKey = "jobs.registry.claim_query.timeout"
2728
)
2829

2930
const (
@@ -122,6 +123,14 @@ var (
122123
"the list, comma separated, of named pausepoints currently enabled for debugging",
123124
"",
124125
)
126+
127+
claimQueryTimeout = settings.RegisterDurationSetting(
128+
settings.ApplicationLevel,
129+
claimQueryTimeoutKey,
130+
"the timeout for the claim query used when adopting jobs",
131+
time.Minute,
132+
settings.PositiveDuration,
133+
)
125134
)
126135

127136
// jitter adds a small jitter in the given duration.

0 commit comments

Comments
 (0)