Netflix / astyanax

Cassandra Java Client
Apache License 2.0
1.04k stars 355 forks source link

TokenPartitionedTopology is not removing tokens that are no longer in the ring #564

Open dkelw opened 9 years ago

dkelw commented 9 years ago

We found when old node is removed from cluster, the tokens in astynanx are not removed, and when new node joins, new tokens are added. This makes the total number of tokens (partitions) at client side is more than server side.

At line 177~181 of TokenPartitionedTopology.java, the logic is to remove the tokens that are no longer in the ring. However, the .remove() method is called on tokenHostMap, which is a local variable and is discarded then. It should be called on this.tokenToPartitionMap.

177 // Remove the tokens that are no longer in the ring 178 for (BigInteger token : tokensToRemove) { 179 tokenHostMap.remove(token); 180 didChange = true; 181 }