Purge expired RS authorization codes from a recurring job class #274

Merged
raucao merged 1 commits from bugfix/solid_queues_prod into master 2026-11-27 12:06:38 +00:00
Owner

Production was logging failures for the purge_rs_authorization_codes recurring task:

NameError: uninitialized constant SolidQueue::RecurringJob::RsAuthorizationCode
(eval at .../solid_queue-1.1.5/app/jobs/solid_queue/recurring_job.rb:7):1:in `perform'

The task used a command: string, which Solid Queue evals inside its own SolidQueue::RecurringJob. That only resolves the constant if the process executing it has the class loaded, and the task is only ever visible in Mission Control as SolidQueue::RecurringJob rather than under a real job name. The recorded stack trace came from a worker on Rails 8.0.2 / solid_queue 1.1.5 — a stale process from before the Rails 8.1 upgrade picking jobs off the shared queue database.

This moves the cleanup into a normal Active Job, so the scheduler enqueues PurgeRsAuthorizationCodesJob on the default queue. It no longer relies on evaling a string and shows up under its own class name. The query and the hourly schedule are unchanged.

Changes:

  • app/jobs/purge_rs_authorization_codes_job.rb — new job holding the existing RsAuthorizationCode.where(expires_at: ..1.hour.ago).delete_all query.
  • config/recurring.yml — task now uses class: PurgeRsAuthorizationCodesJob instead of command:.
  • spec/jobs/purge_rs_authorization_codes_job_spec.rb — covers deletion beyond the one-hour grace period and retention of recently expired/active codes (2 examples, green).

Note: this change on its own won't stop the production errors while the stale worker/VM that recorded the trace is still running; that process needs to be stopped separately.

Production was logging failures for the `purge_rs_authorization_codes` recurring task: ``` NameError: uninitialized constant SolidQueue::RecurringJob::RsAuthorizationCode (eval at .../solid_queue-1.1.5/app/jobs/solid_queue/recurring_job.rb:7):1:in `perform' ``` The task used a `command:` string, which Solid Queue `eval`s inside its own `SolidQueue::RecurringJob`. That only resolves the constant if the process executing it has the class loaded, and the task is only ever visible in Mission Control as `SolidQueue::RecurringJob` rather than under a real job name. The recorded stack trace came from a worker on Rails 8.0.2 / solid_queue 1.1.5 — a stale process from before the Rails 8.1 upgrade picking jobs off the shared queue database. This moves the cleanup into a normal Active Job, so the scheduler enqueues `PurgeRsAuthorizationCodesJob` on the `default` queue. It no longer relies on `eval`ing a string and shows up under its own class name. The query and the hourly schedule are unchanged. Changes: - `app/jobs/purge_rs_authorization_codes_job.rb` — new job holding the existing `RsAuthorizationCode.where(expires_at: ..1.hour.ago).delete_all` query. - `config/recurring.yml` — task now uses `class: PurgeRsAuthorizationCodesJob` instead of `command:`. - `spec/jobs/purge_rs_authorization_codes_job_spec.rb` — covers deletion beyond the one-hour grace period and retention of recently expired/active codes (2 examples, green). Note: this change on its own won't stop the production errors while the stale worker/VM that recorded the trace is still running; that process needs to be stopped separately.
raucao added 1 commit 2026-11-27 12:05:34 +00:00
Purge expired RS authorization codes from a recurring job class
CI / Test (pull_request) Successful in 50s
Release Drafter / Update release notes draft (pull_request) Successful in 3s
5c7234e7d4
The recurring cleanup task used a `command:` string, which Solid Queue evals inside SolidQueue::RecurringJob. It failed in production with `uninitialized constant ...::RsAuthorizationCode` and is only visible in Mission Control as SolidQueue::RecurringJob. Move the cleanup into a regular Active Job class so the task is enqueued as PurgeRsAuthorizationCodesJob on the default queue, appears under its own name, and no longer depends on eval'ing a string.
raucao added the bugkredits-1ops labels 2026-11-27 12:06:27 +00:00
raucao merged commit 1a49a5c3a9 into master 2026-11-27 12:06:38 +00:00
raucao deleted branch bugfix/solid_queues_prod 2026-11-27 12:06:39 +00:00
Sign in to join this conversation.