fix: back off on fetch failure instead of tight-looping#120
Open
klaidliadon wants to merge 1 commit intolestrrat-go:v3from
Open
fix: back off on fetch failure instead of tight-looping#120klaidliadon wants to merge 1 commit intolestrrat-go:v3from
klaidliadon wants to merge 1 commit intolestrrat-go:v3from
Conversation
When Sync() fails at the HTTP request level (connection refused, DNS failure, timeout), set Next to now+MinInterval so the resource is not immediately rescheduled. Previously Next stayed at epoch, causing the backend to dispatch the resource every ~1 second in a tight loop. Fixes lestrrat-go#119
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.
Summary
When
Sync()fails at the HTTP request level (connection refused, DNS failure, timeout),Nextwas left at its initial value (epoch), causing the backend to re-dispatch the resource every ~1 second in a tight retry loop.This patch sets
Nexttonow + MinIntervalon the error path, so failed resources back off before retrying.Fixes #119
What changed
resource.go:Sync()now callsr.SetNext(time.Now().Add(r.MinInterval()))whenhttpcl.Do(req)returns an errorresource_test.go: new testnetwork error backs off instead of tight-looping— verifiesNextis pushed forward after a connection failureTest plan
TestResourceErrorHandling/network_error_backs_off_instead_of_tight-looping