Removing jobs
Sometimes it is necessary to remove a job. For example, there could be a job that has bad data.
typescript
import { Queue } from 'bullmq';
const queue = new Queue('paint');
const job = await queue.add('wall', { color: 1 });
await job.remove();python
from bullmq import Queue
queue = Queue('paint')
job = await queue.add('wall', {'color': 1})
await job.remove()rust
use bullmq::{Queue, QueueOptions};
let queue = Queue::new("paint", QueueOptions::default()).await?;
let job = queue.add("wall", serde_json::json!({"color": 1}), None).await?;
queue.remove(job.id()).await?;WARNING
Locked jobs (in active state) can not be removed. An error will be thrown.
Having a parent job
There are 2 possible cases:
- There are not pending dependencies; in this case the parent is moved to wait status, we may try to process this job.
- There are pending dependencies; in this case the parent is kept in waiting-children status.
INFO
Take into consideration that processed values will be kept in processed hset from the parent if this child is in completed state at the time when it's removed.
Having pending dependencies
We may try to remove all its pending descendants first.
WARNING
If any of the children are locked, the deletion process will be stopped.