Wrap MetricsCollector initialization in log_exceptions#268
Closed
ScotterC wants to merge 1 commit into
Closed
Conversation
MetricsCollector#initialize can run DB queries (e.g., GoodJob fetches queue names via SELECT distinct queue_name). If the database is under load and the query hits a statement timeout (PG::QueryCanceled), the exception propagates through Reporter#start! and crashes the process. The collect() method is already wrapped in log_exceptions, but the .new call was not. This applies the same protection to initialization, consistent with how transient errors are handled elsewhere. If a collector fails to initialize, it's skipped and the reporter continues with the remaining collectors. If all collectors fail, the reporter logs a warning and returns without starting the loop. Fixes judoscale#267 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Member
|
@ScotterC appreciate the issue and pull request! We discussed this a bit, and are leaning towards going a slightly different direction, by sidestepping the issue entirely, and removing the init methods that eagerly load queues and force a potential DB / Redis connection. This would leave I have a WIP change here: #269 |
Member
|
@ScotterC I just released a new v1.13.2 which removes the init eager loading of queues in favor of fetching them on the first collect, which should hopefully handle this better going forward. Please let us know how that works for you. Thanks again for your report. |
Author
|
Great. I'll try it out |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
MetricsCollector#initialize can run DB queries (e.g., GoodJob fetches queue names via SELECT distinct queue_name). If the database is under load and the query hits a statement timeout (PG::QueryCanceled), the exception propagates through Reporter#start! and crashes the process.
The collect() method is already wrapped in log_exceptions, but the .new call was not. This applies the same protection to initialization, consistent with how transient errors are handled elsewhere.
If a collector fails to initialize, it's skipped and the reporter continues with the remaining collectors. If all collectors fail, the reporter logs a warning and returns without starting the loop.
Fixes #267