-
-
Notifications
You must be signed in to change notification settings - Fork 188
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
BUGFIX: Add exponential backoff when reading from Redis #3344
Open
kdambekalns
wants to merge
2
commits into
neos:8.3
Choose a base branch
from
kdambekalns:bugfix/3284-redis-cache-read-backoff
base: 8.3
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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.
Seems dangerous to me.. Isn't there at least a more specific exception that is thrown when "Redis is not ready (yet)"?
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.
No, you can only inspect the error message.
But then again, even if it's something else, why not try again? What could be dangerous?
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.
I'm not sure but I've seen so many errors in the past due to silently caught exceptions that those make me suspicious.
Also we have seen some performance issues with exponential back offs in the past (and are replacing those in Neos 9). For example: Some error in Redis will now lead to a 20s+ delay (if I counted correctly) until it is displayed. A wrong configuration could easily build up to kill the server upon deployments.
What about moving this logic to the getStatus() implementation and make sure that it is called upon deployment?
And/or implement the
WithSetupInterface
and put it thereThere 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.
Yeah, maybe logging the exceptions would be good – after all, at that point nothing should go wrong.
About killing something on a deployment: The use case for me here is exactly a deployment failure. 🙃
Adding something else to explicitly call won't happen (in "my" current project), as we have that workaround already: Call
doctrine:compileproxies
after deployment until no error appears… 🙈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.
Right, it fixes the error you described in the issue, but it might create a new one for misconfigured backends.
I won't block this, but I'm not a big fan as you might be able to tell :)
What about turning this into a composition, i.e. introduce some
RetryBackend
that can be wrapped around any other backend (similar to theMultiBackend
)?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.
That is also an option…
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.
I think that the PDO and Redis backend should both have a automatic retry implementation like this by default. In modern hosting environments, there will be movement and it can happen that a Redis is gone for a second or two once in a while. Therefore, it would be nice if a Flow dev wouldn't have to think about this and her application would just work.
I see the point of @bwaidelich that sometimes retries can worsen things. You need to apply the "circuit braker" design pattern for those cases. However, it depends …
I wouldn't like to introduce another wrapper backend since it makes the setup complicated and I think that a reasonable retry is what most people want.
How about making this configurable (on / off and number of retries) using the same option names for RedisBackend, PDOBackend and any other backend which could profit from this?