exq icon indicating copy to clipboard operation
exq copied to clipboard

Can't find running job

Open devnacho opened this issue 3 years ago • 1 comments

Hello :)

I'm not being able to find a running job with Exq.Api.find_job.

Is this expected?

Reproduction steps

  1. I have the following config:
config :exq,
  name: Exq,
  queues: ["default"]
  1. I have the following worker
defmodule TestWorker do
  def perform do
    job =
      Exq.worker_job()
      |> IO.inspect()

    :timer.sleep(50000)
    raise "error"
  end
end
  1. I enqueue the job {:ok, job_id} = Exq.enqueue(Exq, "default", TestWorker, [])

  2. While the job is running I run Exq.Api.find_job(Exq.Api, "default", job_id) and it returns {:ok, nil}

devnacho avatar Feb 01 '21 03:02 devnacho

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.

ananthakumaran avatar Feb 02 '21 12:02 ananthakumaran