Avoid infinite loop when cached mirror redirect keeps failing#5435
Open
bdraco wants to merge 6 commits intoplatformio:developfrom
Open
Avoid infinite loop when cached mirror redirect keeps failing#5435bdraco wants to merge 6 commits intoplatformio:developfrom
bdraco wants to merge 6 commits intoplatformio:developfrom
Conversation
The registry mirror iterator caches the HEAD redirect for one hour, but the cache hit path never advanced _visited_mirrors, and the cached payload did not include X-PIO-Mirror. When a prior run cached a redirect to a mirror that now fails (for example an SSL error on the download), subsequent iterations kept hitting the same cache key and returning the same failing mirror forever, so tool installs looped until interrupted. Store X-PIO-Mirror in the cached payload, and on cache hit only reuse the entry if it names a mirror not already tried; otherwise fall through to a fresh HEAD with bypass set. Stale cache entries written before this change lack X-PIO-Mirror and fall through naturally, so the fix self heals without a manual cache clear.
Cover the cache hit path advancing _visited_mirrors, stale cache entries without X-PIO-Mirror falling through to a fresh HEAD, and new HEAD responses persisting X-PIO-Mirror so later runs can tell whether the cached redirect still names an untried mirror. Each test fails against the previous iterator implementation.
Author
|
This has been a night and day reliability improvement. No more having to delete the cache every few hours |
Member
|
Hi Nick, Thanks for the PR! 🙏 I'll review it. |
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.
The registry mirror iterator caches the HEAD redirect for one hour, but the cache hit path never advanced
_visited_mirrors, and the cached payload did not includeX-PIO-Mirror. When a prior run cached a redirect to a mirror that now fails (for example an SSL error on the download), subsequent iterations kept hitting the same cache key and returning the same failing mirror forever, so tool installs looped until interrupted.The fix stores
X-PIO-Mirrorin the cached payload, and on cache hit only reuses the entry if it names a mirror not already tried; otherwise it falls through to a fresh HEAD withbypassset. Stale cache entries written before this change lackX-PIO-Mirrorand fall through naturally, so no manual cache clear is required.Before
After
The iterator now advances to a working mirror after the first failure, and if every mirror fails the loop terminates with a clear error instead of spinning forever.