Skip to content

Being able to notify the job/queue to avoid stalling when job is CPU intensive #2857

Closed
@maxime-dupuis

Description

@maxime-dupuis

Is your feature request related to a problem? Please describe.

My CPU intensive jobs would do "correct" work, but they stall with errors:

  • Missing lock for job JOB_ID
  • Error: job stalled more than allowable limit
async checkStaleCreatives(): Promise<any> {
    // Keep busy
    const startTime = Date.now();
    while (Date.now() - startTime < 30000) {
        // Spin
    }
}

image

Describe the solution you'd like

I'd like a way to tell BullMQ that my job is still working correctly. So that my job is not considered stalled.


await job.notifyNotStalled()
or
await queue.notifyNotStalled()

AND/OR the snippet below (or a better fix) should be in the documentation about stalled jobs so people know how to prevent the stalls

Describe alternatives you've considered

Adding this in the CPU intensive loop solves my problem

// Yield to the event loop to avoid stalls
await new Promise((resolve) => setTimeout(resolve));

image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions