-
Notifications
You must be signed in to change notification settings - Fork 21
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
Retry **every** database error #698
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
a3f8d6a
`db`: Log retried queries and give up after 5 minutes
lippserd 33e07c4
Retry **every** database error
lippserd e04087c
Retention: Also retry `DELETE` statements
lippserd 8ef8a06
`retry`: Don't cancel `RetryableFunc` if it exceeds `Timeout`
lippserd 4112b26
Revert "retry: if stopped due to outer context, return that error"
lippserd a468703
`retry`: `return` immediately after context errors
lippserd ed6aab8
`retry`: Reduce `nil` checks for errors
lippserd 9393333
`HA.retry()`: Always use context with a deadline
lippserd 81085c0
`HA`: Give up retrying after 5 minutes
lippserd 3a664c1
Consolidate default retry timeout and settings
lippserd 357bcdb
`retry`: Execute on error callbacks for retryable errors only
lippserd 51a6ef2
`retry`: Explicitly check context for error
lippserd c2b449d
`HA`: Don't log retry count
lippserd 2b3a5d4
`retry`: Set `attempt`'s initial value to `1`
lippserd 3a3baaf
`retry`: Mitigate timing issues
lippserd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the nesting of the
retry.WithBackoff()
within those in other places that execute SQL queries and these backoff settings, some strange effects can be observed: If you stop your database for something like 4m30s, you may see some attempts recovering and others - quite some time after that - failing fatally because those exceeded the 5 minutes. I believe this happens to the maximal backoff of a minute given here, i.e. there may be a minute without an attempt and after that, both the inner and outer 5 minute timeout are exceeded.Also, if we're adding
retry.WithBackoff()
, do we even still need it here? Just for fun, I removed all the retry from this function (so that it just doesConnect()
andinitConn()
with no loops or anything around it) and it seemed to work more reliably, only the logging became very annoying with queries and stacktraces within a single line.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The following changes address your considerations:
HA
now uses aTimer
instead of aTicker
that is reset properly even if expired (and not yet drained): 81085c0.If the timeout expires during the sleep phase between attempts one final retry attempt will be made: 3a3baaf.
I have something in my stash which fixes this.
zap
adds theerrorVerbose
field if the error implementsfmt.Formatter
which is true for all our wrapped errors. Simple solution would be to replacezap.Error()
calls with a custom implementation that returns a "silent" error, e.g.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However, the PR just keeps the nested retrying for now, thereby avoiding this issue.