Minor token ring creation optimization + rebuild token rings on hosts refresh - #472
Open
toptobes wants to merge 1 commit into
Open
Minor token ring creation optimization + rebuild token rings on hosts refresh#472toptobes wants to merge 1 commit into
toptobes wants to merge 1 commit into
Conversation
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.
Improves a couple aspects of token ring handling, namely:
_refreshHostsThe second is the more important change, this way token-aware routing isn't broken due to topology changes during the runtime of the session (plus,
metadata.getTokenRanges()is also a public method, so users could technically be consuming stale information)As a precedent, I checked Go's implementation which refreshes the ring on one of three conditions (see
host_source.go):_refresh()calls_refreshHosts()_nodeTopologyChangeHandler()puts_refreshHosts()in the debouncerI believe Java is similar to Go here, though I didn't look too long/hard at it (its implementation was a little harder to follow)
This is definitely not my ideal implementation by any means, but it's the minimal fix. The topology events definitely should have their own dedicated debouncer, but that's out of scope for this PR.
Additional notes:
_refreshHosts()specifically as there were no existing tests for that method.buildTokens()has to explicitly invalidateskeyspaces[*].replicasnow; this wasn't an issue before since there were never any replicas prior to the token ring being built during initialization