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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

- Fix bug in worker-level stuck job detection. [PR #1133](https://github.com/riverqueue/river/pull/1133).

## [0.30.1] - 2026-01-19

### Fixed
Expand Down
6 changes: 3 additions & 3 deletions internal/jobexecutor/job_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ func (e *JobExecutor) execute(ctx context.Context) (res *jobExecutorResult) {
ctx, timeoutCancel = context.WithTimeout(ctx, jobTimeout)
defer timeoutCancel()

watchStuckCancel := e.watchStuck(ctx)
watchStuckCancel := e.watchStuck(ctx, jobTimeout)
defer watchStuckCancel()
}

Expand Down Expand Up @@ -266,7 +266,7 @@ func (e *JobExecutor) execute(ctx context.Context) (res *jobExecutorResult) {
// Currently we don't do anything if we notice a job is stuck. Knowing about
// stuck jobs is just used for informational purposes in the producer in
// generating periodic stats.
func (e *JobExecutor) watchStuck(ctx context.Context) context.CancelFunc {
func (e *JobExecutor) watchStuck(ctx context.Context, jobTimeout time.Duration) context.CancelFunc {
// We add a WithoutCancel here so that this inner goroutine becomes
// immune to all context cancellations _except_ the one where it's
// cancelled because we leave JobExecutor.execute.
Expand All @@ -281,7 +281,7 @@ func (e *JobExecutor) watchStuck(ctx context.Context) context.CancelFunc {
case <-ctx.Done():
// context cancelled as we leave JobExecutor.execute

case <-time.After(e.ClientJobTimeout + cmp.Or(e.StuckThresholdOverride, stuckThresholdDefault)):
case <-time.After(jobTimeout + cmp.Or(e.StuckThresholdOverride, stuckThresholdDefault)):
e.ProducerCallbacks.Stuck()

e.Logger.WarnContext(ctx, e.Name+": Job appears to be stuck",
Expand Down
Loading