exq
exq copied to clipboard
Can't find running job
Hello :)
I'm not being able to find a running job with Exq.Api.find_job.
Is this expected?
Reproduction steps
- I have the following config:
config :exq,
name: Exq,
queues: ["default"]
- I have the following worker
defmodule TestWorker do
def perform do
job =
Exq.worker_job()
|> IO.inspect()
:timer.sleep(50000)
raise "error"
end
end
-
I enqueue the job
{:ok, job_id} = Exq.enqueue(Exq, "default", TestWorker, []) -
While the job is running I run
Exq.Api.find_job(Exq.Api, "default", job_id)and it returns{:ok, nil}
I'm not being able to find a running job with Exq.Api.find_job.
Because running jobs are removed from the main queue once the job is picked up for execution (it will be in backup queue). In general using find_job by jid is not recommended as the jobs are stored in LIST and it's not possible to find the specific job in O(1). This could cause issues with big queues. AFAIK, there is no efficient way to do it in sidekiq as well.