toptobes opened a new pull request, #472: URL: https://github.com/apache/cassandra-nodejs-driver/pull/472
Improves a couple aspects of token ring handling, namely: - Brings token ring initialization from O(N^2) -> O(N log N) - Always rebuilds token rings in `_refreshHosts` The 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`): - Reconnection <- ✅ `_refresh()` calls `_refreshHosts()` - Topology events <- ✅ `_nodeTopologyChangeHandler()` puts `_refreshHosts()` in the debouncer - On NODE UP _when the host is not recognized_ <- ❌ not sure how necessary this is; it seems on the defensive side I 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: - I did not write any tests for `_refreshHosts()` specifically as there were no existing tests for that method. - `buildTokens()` has to explicitly invalidates `keyspaces[*].replicas` now; this wasn't an issue before since there were never any replicas prior to the token ring being built during initialization -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
