-
Notifications
You must be signed in to change notification settings - Fork 69
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
A corner case will cause panic. #13
Comments
It seems this condition is wrong(https://github.com/buraksezer/consistent/blob/master/consistent.go#L163):
Is it reanable to remove equal?:
|
Hello, Your configuration is invalid. So this is the expected behavior. You should use something like that: // Create a new consistent instance
cfg := consistent.Config{
PartitionCount: 7,
ReplicationFactor: 20,
Load: 1.25,
Hasher: hasher{},
} Configuration section in README file explains these variables https://github.com/buraksezer/consistent#configuration If you explain your use case, I may help further for the configuration. Thanks! |
I have checked the definition of variables in
One node with one replication for one partition seems reasonable. |
@buraksezer is it possible for you to fix what @ShiKaiWi is reporting? i'm running into a similar issue as well. this patch seems reasonable and that's what i did to keep going. we may want to run (unit/functional) tests where we try to squeeze a small number of partitions on a single node and the logic here does seem incorrect. the if you wish, i can create a pr as well. please let us know. |
@sriramch firstly, I'm so sorry for the late response. The reported configuration by @ShiKaiWi was invalid. Why do you want to use a consistent hash function if you have only one partition? If you provide a sample configuration, I may understand what the actual problem is. I'm OK with the changes, if it fixes a real problem. |
@buraksezer thanks for responding! as i mentioned earlier, we may want to run unit/functional tests with a smaller number of partitions on one or few nodes with just 1 replica to simulate some failure scenarios. for instance, the following would panic. here the
my earlier comment explains the cause and a potential fix. why can't it be accommodated, and why is it invalid to have a non trivial number of partitions on one or a couple of nodes with one replica? why is this incorrect conceptually? shouldn't the |
@ShiKaiWi @sriramch I think @buraksezer is right.
Meanwhile for @buraksezer I have a mathematical question on the parameter settings. Is it possible to derive mathematically that a given the values for parameters In addition to that, what would be a good parameter set for production environment? (good as in, just valid. performant wise I can definitely benchmark test). Let's say on average, I will have 5.6 members. Variance 1.2 memberSquare. |
@iqDF - thanks for your comments.
that is an implementation detail. as i asked earlier, conceptually why is distributing a non trivial number of partitions over one or a couple of nodes with one replica incorrect (with a load factor > 1)?
it should and i have mentioned it here as well last line in the 2nd paragraph
can you please provide some examples? i was under the impression that we should be able to accommodate |
I am hitting this same issue, config is:
I add a single member, and get the same panic as above. The panic occurs because replicationFactor is 1, so, after a single member is added there is only one entry in c.sortedSet. This means count is always equal to len(sortedSet):
And it always panics. Note that here the load has not been exceeded - load = 100, maximum load = 125. What am I doing wrong here? |
Hey, @purplefox I think we should add a check that validates the configuration. |
I am creating a non replicated, but distributed cache. There are multiple members in the cluster and a particular key should live on exactly one member. I am using consistent hashing to determine which member the key lives on. A key only lives on one member so it is not replicated, so replication factor is 1. This seems like a very common use case for consistent hashing (e.g. redis and many other things) |
You should know that this package implements a modified version of this algorithm for Olric. |
Thanks. If replication factor does not mean what I thought it meant, what does it represent? |
It's related to the consistent hashing technique: https://ably.com/blog/implementing-efficient-consistent-hashing |
I think you're referring to a technique in consistent hashing where a server node is added multiple times on the ring (not just once) in order to make distribution more uniform. I am familiar with this technique but never heard it called "replication factor" before. IMO using the term "replication factor" is somewhat confusing as that term already. has a well known meaning in distributed systems. Thanks for the quick reply. |
This demo will panic:
Here is the error message:
So this is expected behavior or a bug?
The text was updated successfully, but these errors were encountered: