Skip to content

Commit 024f9e6

Browse files
committed
Prevent hash ring positional collisions
1 parent 4c5a8ca commit 024f9e6

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lib/carbon/hashing.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ def add_node(self, node):
2323
for i in range(self.replica_count):
2424
replica_key = "%s:%d" % (node, i)
2525
position = self.compute_ring_position(replica_key)
26+
while position in [r[0] for r in self.ring]:
27+
position = position + 1
2628
entry = (position, node)
2729
bisect.insort(self.ring, entry)
2830

0 commit comments

Comments
 (0)