bitwalker / bitwalker/libring

HashRing.key_to_nodes/3 gives unexpected results

Open
#39 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Elixir
Stars
228
Forks
29
PR merge metrics
No merged PRs in 30d

Description

Given this ring:
```
iex> ring = HashRing.new()
|> HashRing.add_node(:a@localhost)
|> HashRing.add_node(:b@localhost)
#
```

Request to get a list of `2` nodes for the key `14`:

```
iex> HashRing.key_to_nodes(ring, 14, 2)
```

Expected result is 2 nodes:
```
[:a@localhost, :b@localhost]
```

Actual result is one node:
```
[:a@localhost]
```

Forgive me if I'm misreading `HashRing.key_to_nodes/3` but it sounds like if you ask for `2` nodes and your ring has 2 nodes, then the result should contain 2 nodes. If that's not the case, then the docs should be clarified. On the other hand, if this represents a bug in how certain nodes are calculated due to the names (?) of the nodes, then the fix is something more than just clarifying the docs.

See also: https://elixirforum.com/t/unexpected-behavior-from-libring-hashring-unlucky-number-14/69333

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.