Fix nil-DataPoint crash masking real errors in ResqueJobs::RunSimulateDataPoint#853
Merged
Merged
Conversation
…eDataPoint (#846, #848) - find returns nil for deleted DP (raise_not_found_error=false in all envs): skip cleanly w/ logged id instead of NoMethodError - rescue clauses: when d never bound (transient Mongo failure in find), log w/ id and re-raise original so Resque failed queue records root cause, not masking NoMethodError - regression specs reproduce both paths; Resque::* consts stubbed when gem absent (Windows) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Problem
Both rescue clauses in
ResqueJobs::RunSimulateDataPoint.performcalld.add_to_rails_logon a nild, raisingNoMethodError: undefined method 'add_to_rails_log' for nil— masking the root cause in the Resque failed queue and leaving the datapoint permanently stuck in its prior status (#846, observed at k8s/KEDA scale with ~1,500+ workers).Two distinct paths get there (
raise_not_found_error: falsein every env inmongoid.yml):findreturns nil (no DocumentNotFound) →d.get_statusesraises the first NoMethodError → rescue raises the second (the one Resque records)finditself raises →dnever bound → same rescue crashChange
find: logSKIPPING <id>: DataPoint no longer existsand returndis nil, log viaRails.logger.errorwith the datapoint id and re-raise the original error so the failed queue records the root cause; whendis bound, behavior unchanged (log to datapoint, swallow)Test
Regression specs added to
resque_run_simulate_data_point_hardening_spec.rb— written first and verified red on develop (both reproduce the masking NoMethodError), green after the fix (11 examples, 0 failures, run locally against mongod).Resque::*error consts are stubbed when the gem is absent so the spec runs outside the docker stack (resque is not bundled on Windows).Fixes #846. Supersedes #850.
🤖 Generated with Claude Code