Assign a new node after calling update_cluster_info! #355
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.
If we catch a connection error and refresh the cluster topology, we need to re-calculate what node to send the command to in the router; the node we're using might not even be a valid node any longer.
I added two test cases to test_against_cluster_broken.rb which demonstrate this; one with a transaction, and one without. In both cases, without the patch, the first command after a node goes down fails because the client realises it needs to fetch new node info (with
update_cluster_info!
), but then retries the command on the old node still (which doesn't even exist anymore). The patch fixes this.Unfortunately these tests won't pass on CI at the moment because of #354 but they work on my machine if you run them by themseles (with
bundle exec ruby -Itest test/test_against_cluster_broken.rb -n 'test_reloading_on_connection_error'
).