cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sylvain Lebresne (Commented) (JIRA)" <>
Subject [jira] [Commented] (CASSANDRA-3262) SimpleSnitch.compareEndpoints doesn't respect the intent of the snitch
Date Tue, 27 Sep 2011 13:57:11 GMT


Sylvain Lebresne commented on CASSANDRA-3262:

I think there is a misunderstanding. I agree with the pinning of replicas. The problem is
that the current implementation of AbstractEndpointSnitch.compareEndpoints is:
public int compareEndpoints(InetAddress target, InetAddress a1, InetAddress a2)
    return a1.getHostAddress().compareTo(a2.getHostAddress());
If you sort a list of hosts using that, you will always return the host that have the "smallest"
IP. In other words, in a 3 nodes cluster with RF=3, all and every read will hit the exact
same node.

What makes it kind of work today is that this compareEndpoints() method is barely used. It's
used only in the case where the dynamic snitch have no scores for the endpoints. Otherwise,
it's sortByProximity that is used (which doesn't rely on compareEndpoints -- this is confusing
and my patch corrects it). And sortByProximity does *the right thing*, i.e, it doesn't sort
the input list since it is supposed to be in token order (which effectively pin one range
to every replica).

So the patch here proposes two things:
  * If fixes the compareEndpoints method: comparing IP addresses is not a good idea.
  * It refactors the code to make sortByProximity use compareEndpoint, to having getting in
that situation again.
> SimpleSnitch.compareEndpoints doesn't respect the intent of the snitch
> ----------------------------------------------------------------------
>                 Key: CASSANDRA-3262
>                 URL:
>             Project: Cassandra
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 0.8.6
>            Reporter: Sylvain Lebresne
>            Assignee: Sylvain Lebresne
>            Priority: Minor
>             Fix For: 0.8.7, 1.0.0
>         Attachments: 3262.patch
> SimpleSnitch is supposed to not sort the input addresses, thus respecting the order of
the partitioner. However, it's compareEndpoints instead uses IP addresses comparison. Note
that this matter when the dynamicSnitch fall back to the wrapped snitch since it uses the
compareEndpoint method then.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


View raw message