Add retry policy and fix documentation for Cassandra storage backend#10467
Merged
HridoyRoy merged 3 commits intoAug 30, 2022
Merged
Conversation
fix docs for connection_timeout
b34bcef to
fdcab88
Compare
Contributor
Author
|
@ncabatoff, Hi! Could you take a look, please? |
Contributor
|
Enhancement request along with accompanying documentation improvements do seem relevant. Can this be reviewed for release in the near future? |
Contributor
|
Likely related to #15899 - and on merger user on that issue should be advised to retest before closing that issue too. |
Closed
Contributor
|
The changelog check is ok -- I triggered the CI run off another branch and PR, so the check is looking for the wrong changelog entry. |
Zlaticanin
approved these changes
Aug 30, 2022
Contributor
Zlaticanin
left a comment
There was a problem hiding this comment.
LGTM. We gave it a test run and it all seems good! 👍
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.
Shortly, this PR fixes two problems:
More details below...
Current documentation says, that default value for
connection_timeoutis0, you might think there is no timeout by default, but in fact, if we don't set these options timeout will be 600ms.see:
vault/physical/cassandra/cassandra.go
Lines 127 to 133 in 0e8c6c2
cluster.Timeoutis not changing somewhere else and get default value:vault/vendor/github.com/gocql/gocql/cluster.go
Line 49 in 665d668
If we have a Cassandra cluster with several nodes, we don't want to get an error if one of nodes has gone. For supporting this behavior with gocql(which used in Cassandra backend) we must set one of RetryPolicy for the cluster: https://github.com/gocql/gocql/blob/5913df4d474e0b2492a129d17bbb3c04537a15cd/policies.go#L158
By default(current behavior) cluster use "retry on same connection" policy. So, if current active node is down client will get an error:
https://github.com/gocql/gocql/blob/5913df4d474e0b2492a129d17bbb3c04537a15cd/policies.go#L141
We can easily fix this by using SimpleRetryPolicy (retry for another connection) when creating the cluster.
Also, one new option added to set timeout for the initial connection.
I tried to make changes as little as possible.
This PR doesn't change the behavior of current installations.