Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crc32 hash value conflict in add function #13

Open
andyxning opened this issue Dec 7, 2015 · 0 comments
Open

crc32 hash value conflict in add function #13

andyxning opened this issue Dec 7, 2015 · 0 comments

Comments

@andyxning
Copy link

i think we should take crc32 hash value conflict in add function, as shown in

// need c.Lock() before calling
func (c *Consistent) add(elt string) {
    for i := 0; i < c.NumberOfReplicas; i++ {
    c.circle[c.hashKey(c.eltKey(elt, i))] = elt
    }
    c.members[elt] = true
    c.updateSortedHashes()
    c.count++
}

the c.hashKey(c.eltKey(elt, i)) may return a conflict, i.e., a duplicate crc32 hash value and in such a situation we can not guarantee that we can have specified NumberOfReplicas for each node.

For more info, an example can be get in carbon

def add_node(self, node):
    self.nodes.add(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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant