Repository navigation
Fix: Prevent infinite loop in gap_analysis preload (#885) - #895
Open
PRAteek-singHWY wants to merge 5 commits into
Open
PRAteek-singHWY wants to merge 5 commits into
PRAteek-singHWY wants to merge 5 commits into
Conversation
Contributor
Author
…finite-loop # Conflicts: # application/utils/gap_analysis.py
A pair still running under the same job id is no longer a failure, so long GA jobs are not dropped after 10 polls. A changed job id counts as one, because map_analysis only enqueues a new job once the last one ended without a result. preload now reports dropped pairs and no longer logs success when any were dropped. Adds tests.
Ten scattered 503s could otherwise drop a healthy long job. The cap now means failures in a row, and the docstring says a new job also follows an expired in-flight key.
PRAteek-singHWY
requested review from
Pa04rth,
northdpole,
paoga87 and
robvanderveer
as code owners
November 5, 2026 19:56
Contributor
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 59 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
This branch has not been deployed
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.
Fixes #885.
What
preloadinapplication/utils/gap_analysis.pypolls/rest/v1/map_analysisuntil every standard pair is cached. A pair that never succeeds keeps it looping forever: a 404 whenCRE_NO_CALCULATE_GAP_ANALYSISis set or on Heroku, or a job that keeps failing and being re-enqueued. The loop is still on current main.Change
resultnorjob_id, or ajob_idthat changed since the last poll, becausemap_analysisonly enqueues a new job when the last one ended without a result (or its in-flight key expired). The samejob_idagain means the job is still running, so it is not a failure, and it clears earlier failures.PRELOAD_MAX_FAILURES(10) failures in a row, the pair is dropped. Counted per pair.preloadreturns the dropped pairs. It logsmap analysis preloaded successfullyonly when nothing was dropped, and otherwise logs an error listing them.(a, b)tuples, and finished pairs are not polled again. No sleep after the last pass.Why the first version of this PR was wrong
It counted "job still running" as a failure. GA jobs may run for 36 hours (
GAP_ANALYSIS_TIMEOUT), so a healthy job needing 51 polls was dropped at poll 10, and the run then printed "preloaded successfully". Reworked after a self-review on 2026-11-05.Tests
application/tests/gap_analysis_preload_test.py, 8 tests, no network: all cached means one pass and no sleep; a finished pair is not polled again; a long-running job is not dropped; scattered 503s while a job runs do not drop it; a pair that keeps returning 404 is dropped after 10; a job that keeps failing and re-enqueuing is dropped; failures are counted per pair; success is not logged when pairs were dropped. Six of the first seven fail against the earlier version of this PR.Proof
Full suite merged with current main: 1105 tests OK (skipped=6). black clean, no new mypy errors.
Limits
cre_main.pyignores the return value, so the process still exits 0 when pairs were dropped; only the error log reports it.