Skip to content

Prevent scanning for worker queues on init#269

Merged
carlosantoniodasilva merged 2 commits into
mainfrom
ca-prevent-query-on-init
Mar 5, 2026
Merged

Prevent scanning for worker queues on init#269
carlosantoniodasilva merged 2 commits into
mainfrom
ca-prevent-query-on-init

Conversation

@carlosantoniodasilva
Copy link
Copy Markdown
Member

@carlosantoniodasilva carlosantoniodasilva commented Mar 4, 2026

Connecting to the DB or Redis on init might be problematic if that connection / query can't be quickly executed, or raises an exception / times out, because it could crash the reporter and with it the whole process.

This eliminates the init methods, and leave the queue discovery to the collection time, which already runs inside the reporter thread, and are wrapped in proper exception handling.

Another benefit of leaving this to the collection time is that we should have faster init/boot time for GoodJob & SolidQueue adapters.

Closes #267
Closes #268

Ref.: judoscale/judoscale-python#131

Connecting to the DB or Redis on init might be problematic if that
connection / query can't be quickly executed, or raises an exception /
times out, because it could crash the reporter and with it the whole
process.

This eliminates the init methods, and leave the queue discovery to the
collection time, which already runs inside the reporter thread, and are
wrapped in proper exception handling.

Another benefit of leaving this to the collection time is that we should
have faster init/boot time for GoodJob & SolidQueue adapters.

One potential drawback is that we won't auto-discover queues that don't
have a pending/enqueued job, until they actually do, so they may not
show up initially. But it should not be a problem in terms of
autoscaling behavior.
This guarantees we'll report all known queues with every collect, but
instead of eagerly loading it on init, we're doing it on first collect
when the queues list is empty.
@carlosantoniodasilva carlosantoniodasilva changed the title Remove init methods that eagerly loaded queues to prevent DB connection Prevent scanning for worker queues on init Mar 4, 2026
@carlosantoniodasilva carlosantoniodasilva marked this pull request as ready for review March 4, 2026 19:45
Copy link
Copy Markdown
Member

@adamlogic adamlogic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@carlosantoniodasilva carlosantoniodasilva merged commit 345c0e2 into main Mar 5, 2026
123 checks passed
@carlosantoniodasilva carlosantoniodasilva deleted the ca-prevent-query-on-init branch March 5, 2026 11:48
carlosantoniodasilva added a commit to judoscale/judoscale-python that referenced this pull request Mar 5, 2026
Connecting to the DB or Redis on init might be problematic if that connection / query can't be quickly executed, or raises an exception / times out, because it could crash the reporter and with it the whole process.

This eliminates the scanning on init, and leave the queue discovery to the collection time, which already runs inside the reporter thread, and are wrapped in proper exception handling.

Ref.: judoscale/judoscale-ruby#269
carlosantoniodasilva pushed a commit that referenced this pull request Mar 5, 2026
## [1.13.2](v1.13.1...v1.13.2) (2026-03-05)


### Bug Fixes

* Prevent scanning for worker queues on init ([#269](#269)) ([345c0e2](345c0e2))

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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

Successfully merging this pull request may close these issues.

MetricsCollector#initialize crashes process on DB timeout (PG::QueryCanceled)

2 participants