rails / solid_queue

Database-backed Active Job backend
MIT License
1.84k stars 110 forks source link

Exception SolidQueue::ReadyExecution.claim #230

Closed luigi7up closed 4 months ago

luigi7up commented 4 months ago

Hi!

I've created a Service like object (Scraper class) in my Rails app that now I want to run as a Job. I'm usually using Sidekiq to run async jobs, but I want to try solid_queue. What I did is I simply created a new job (ScraperJob) and in the perform method I instantiate my scraper and call the scraper.run(). When I call ScraperJob.perform_later I see the job is getting queued ([SolidQueue] Claimed 1 jobs) and I see some logs coming from the service which indicates that it is truly running.

However, I'm noticing that the job is failing and restarting because of the following exception:

SolidQueue::ReadyExecution Create (0.7ms)  INSERT INTO "solid_queue_ready_executions" ("job_id", "queue_name", "priority", "created_at") VALUES ($1, $2, $3, $4) RETURNING "id"  [["job_id", 7], ["queue_name", "default"], ["priority", 0], ["created_at", "2024-05-21 19:16:11.026601"]]
web    |   TRANSACTION (0.1ms)  RELEASE SAVEPOINT active_record_1
web    |   SolidQueue::ClaimedExecution Destroy (0.2ms)  DELETE FROM "solid_queue_claimed_executions" WHERE "solid_queue_claimed_executions"."id" = $1  [["id", 14]]
web    |   TRANSACTION (1.0ms)  COMMIT
web    | [ActiveJob] [NjuskaloScraperJob] [0f6e695b-e35f-4109-8e4e-086cf52783c3] Performed NjuskaloScraperJob (Job ID: 0f6e695b-e35f-4109-8e4e-086cf52783c3) from SolidQueue(default) in 5032.35ms
web    | /Users/luka/.rvm/gems/ruby-3.1.2/gems/solid_queue-0.1.2/lib/solid_queue/worker.rb:35:in `block in poll': uninitialized constant SolidQueue::ReadyExecution (NameError)
web    |
web    |           SolidQueue::ReadyExecution.claim(queues, pool.idle_threads, process.id)
web    |                     ^^^^^^^^^^^^^^^^
web    | Did you mean?  SolidQueue::FailedExecution
web    |    from /Users/luka/.rvm/gems/ruby-3.1.2/gems/solid_queue-0.1.2/lib/solid_queue/processes/poller.rb:14:in `block in with_polling_volume'
web    |    from /Users/luka/.rvm/gems/ruby-3.1.2/gems/activesupport-7.1.3.3/lib/active_support/logger_silence.rb:18:in `block in silence'
web    |    from /Users/luka/.rvm/gems/ruby-3.1.2/gems/activesupport-7.1.3.3/lib/active_support/logger_thread_safe_level.rb:45:in `log_at'
web    |    from /Users/luka/.rvm/gems/ruby-3.1.2/gems/activesupport-7.1.3.3/lib/active_support/logger_silence.rb:18:in `silence'
web    |    from /Users/luka/.rvm/gems/ruby-3.1.2/gems/solid_queue-0.1.2/lib/solid_queue/processes/poller.rb:14:in `with_polling_volume'
web    |    from /Users/luka/.rvm/gems/ruby-3.1.2/gems/solid_queue-0.1.2/lib/solid_queue/worker.rb:34:in `poll'
web    |    from /Users/luka/.rvm/gems/ruby-3.1.2/gems/solid_queue-0.1.2/lib/solid_queue/worker.rb:19:in `run'
web    |    from /Users/luka/.rvm/gems/ruby-3.1.2/gems/solid_queue-0.1.2/lib/solid_queue/processes/runnable.rb:47:in `block in do_start_loop'

My setup is:

Please tell me if you need more info

rosa commented 4 months ago

Hey @luigi7up, could you try running the last version of Solid Queue and see if it still happens?

luigi7up commented 4 months ago

Hi @rosa actually you helped me already in the mission control github repo :) Yes, updating solid_queue with bundle update solid_queue solved the issue