Skip to content

fix: back off on fetch failure instead of tight-looping#120

Open
klaidliadon wants to merge 1 commit intolestrrat-go:v3from
klaidliadon:fix/backoff-on-fetch-failure
Open

fix: back off on fetch failure instead of tight-looping#120
klaidliadon wants to merge 1 commit intolestrrat-go:v3from
klaidliadon:fix/backoff-on-fetch-failure

Conversation

@klaidliadon
Copy link
Copy Markdown

Summary

When Sync() fails at the HTTP request level (connection refused, DNS failure, timeout), Next was 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 Next to now + MinInterval on the error path, so failed resources back off before retrying.

Fixes #119

What changed

  • resource.go: Sync() now calls r.SetNext(time.Now().Add(r.MinInterval())) when httpcl.Do(req) returns an error
  • resource_test.go: new test network error backs off instead of tight-looping — verifies Next is pushed forward after a connection failure

Test plan

  • New test: TestResourceErrorHandling/network_error_backs_off_instead_of_tight-looping
  • Full suite: 143 tests pass

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Worker goroutines block indefinitely on unreachable hosts, ignore context cancellation

1 participant