Skip to content

Commit

Permalink
GITBOOK-177: change request with no subject merged in GitBook
Browse files Browse the repository at this point in the history
  • Loading branch information
manast authored and gitbook-bot committed Jul 22, 2023
1 parent 59d4d1d commit 6ffb50b
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions docs/gitbook/guide/jobs/stalled.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
# Stalled

{% hint style="info" %}
Stalled jobs checks will only work if there is at least one [`QueueScheduler`](../queuescheduler.md) instance configured in the Queue.
{% endhint %}

{% hint style="danger" %}
From BullMQ 2.0 and onwards, the QueueScheduler is not needed anymore.
For manually fetching jobs check this [pattern](https://docs.bullmq.io/patterns/manually-fetching-jobs#checking-for-stalled-jobs)
From BullMQ 2.0 and onwards, the QueueScheduler is not needed anymore. For manually fetching jobs check this [pattern](https://docs.bullmq.io/patterns/manually-fetching-jobs#checking-for-stalled-jobs)
{% endhint %}

When a job is in an active state, i.e., it is being processed by a worker, it needs to continuously update the queue to notify that the worker is still working on the job. This mechanism prevents a worker that crashes or enters an endless loop from keeping a job in an active state forever.
Expand All @@ -17,9 +12,11 @@ When a worker is not able to notify the queue that it is still working on a give
There is not a 'stalled' state, only a 'stalled' event emitted when a job is automatically moved from active to waiting state.
{% endhint %}

If a job stalls more than a predefined limit (see the maxStalledCount option [https://api.docs.bullmq.io/interfaces/v4.WorkerOptions.html#maxStalledCount](https://api.docs.bullmq.io/interfaces/v4.WorkerOptions.html#maxStalledCount)), the job will be failed permanently with the error "_job stalled more than allowable limit_". The default is 1, as stalled jobs should be a rare occurrence, but you can increase this number if needed.

In order to avoid stalled jobs, make sure that your worker does not keep Node.js event loop too busy, the default max stalled check duration is 30 seconds, so as long as you do not perform CPU operations exceeding that value you should not get stalled jobs.

Another way to reduce the chance for stalled jobs is using so called "sandboxed" processors. In this case, the workers will spawn new separate Node.js processes, running separately from the main process.
Another way to reduce the chance of stalled jobs is using so-called "sandboxed" processors. In this case, the workers will spawn new separate Node.js processes, running separately from the main process.

{% code title="main.ts" %}
```typescript
Expand Down

0 comments on commit 6ffb50b

Please sign in to comment.