From 024f9e67ca47619438951c59154c0dec0b0518c7 Mon Sep 17 00:00:00 2001 From: Scott Sanders Date: Tue, 17 Dec 2013 09:59:52 -0500 Subject: [PATCH] Prevent hash ring positional collisions --- lib/carbon/hashing.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/carbon/hashing.py b/lib/carbon/hashing.py index 3c4d0be2f..34ebce28e 100644 --- a/lib/carbon/hashing.py +++ b/lib/carbon/hashing.py @@ -23,6 +23,8 @@ def add_node(self, node): for i in range(self.replica_count): replica_key = "%s:%d" % (node, i) position = self.compute_ring_position(replica_key) + while position in [r[0] for r in self.ring]: + position = position + 1 entry = (position, node) bisect.insort(self.ring, entry)