Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backoff: fix enforcing max backoff #200

Merged
merged 2 commits into from
Dec 5, 2024
Merged

backoff: fix enforcing max backoff #200

merged 2 commits into from
Dec 5, 2024

Conversation

andydunstall
Copy link
Owner

The Piko client uses backoff with jitter to avoid overloading the server when reconnecting, however the client wasn't enforcing max backoff meaning it could grow far too large...

@moredure
Copy link

moredure commented Dec 5, 2024

lgtm

@andydunstall
Copy link
Owner Author

andydunstall commented Dec 5, 2024

Also updated to log how long the backoff is (otherwise it's quite hard to debug):

{"level":"warn","ts":"2024-12-05T10:35:31.167Z","subsystem":"client","msg":"connect failed; retrying","endpoint-id":"my-endpoint","url":"ws://localhost:8001/piko/v1/upstream/my-endpoint","backoff":"109.574759ms","error":"dial tcp 127.0.0.1:8001: connect: connection refused"}
{"level":"warn","ts":"2024-12-05T10:35:31.278Z","subsystem":"client","msg":"connect failed; retrying","endpoint-id":"my-endpoint","url":"ws://localhost:8001/piko/v1/upstream/my-endpoint","backoff":"228.701585ms","error":"dial tcp 127.0.0.1:8001: connect: connection refused"}
{"level":"warn","ts":"2024-12-05T10:35:31.509Z","subsystem":"client","msg":"connect failed; retrying","endpoint-id":"my-endpoint","url":"ws://localhost:8001/piko/v1/upstream/my-endpoint","backoff":"488.785139ms","error":"dial tcp 127.0.0.1:8001: connect: connection refused"}
{"level":"warn","ts":"2024-12-05T10:35:31.999Z","subsystem":"client","msg":"connect failed; retrying","endpoint-id":"my-endpoint","url":"ws://localhost:8001/piko/v1/upstream/my-endpoint","backoff":"1.041538359s","error":"dial tcp 127.0.0.1:8001: connect: connection refused"}
{"level":"warn","ts":"2024-12-05T10:35:33.042Z","subsystem":"client","msg":"connect failed; retrying","endpoint-id":"my-endpoint","url":"ws://localhost:8001/piko/v1/upstream/my-endpoint","backoff":"2.278453609s","error":"dial tcp 127.0.0.1:8001: connect: connection refused"}
{"level":"warn","ts":"2024-12-05T10:35:35.324Z","subsystem":"client","msg":"connect failed; retrying","endpoint-id":"my-endpoint","url":"ws://localhost:8001/piko/v1/upstream/my-endpoint","backoff":"4.77646657s","error":"dial tcp 127.0.0.1:8001: connect: connection refused"}

@andydunstall andydunstall merged commit 1da1354 into main Dec 5, 2024
3 checks passed
@andydunstall andydunstall deleted the fix-max-backoff branch December 5, 2024 10:37
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.

2 participants