Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't find running job #441

Open
devnacho opened this issue Feb 1, 2021 · 1 comment
Open

Can't find running job #441

devnacho opened this issue Feb 1, 2021 · 1 comment

Comments

@devnacho
Copy link

devnacho commented Feb 1, 2021

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}

@ananthakumaran
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants