Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix selection of host by token (apache#1405)
We've seen increased per-query latency after upgrading to latest gocql. This commit fixes the latency issue for us. This partially reverts 7b17705. There were multiple unrelated changes in that commit. The relevant part of that commit's description is: Fix finding the correct token in the token ring for host selection. Unfortunately that description does not contain the details of the issue it was aimed to fix. The change in 7b17705 also made the two binary search implementations (tokenRingReplicas.replicasFor and tokenRing.GetHostForToken) inconsistent, reverting the change fixed this discrepancy as well. The token values returned in system.peers and system.local tables are ends of ranges that the nodes are responsible for[1], so we never need to rollunder. When searching for a node responsible for token X (computed from partition key), we need to find hostTokens with end token Y with the lowest value such that Y >= X. In case X is larger than the largest end token value in tokenRingReplicas, we wrap the ring and the node with the lowest token is responsible (i.e. the hostTokens at index 0). [1] https://docs.datastax.com/en/dse/6.7/dse-arch/datastax_enterprise/dbArch/archAboutDataDistribute.html
- Loading branch information