[ 
https://issues.apache.org/jira/browse/CASSANDRA-6683?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13899375#comment-13899375
 ] 

Tyler Hobbs commented on CASSANDRA-6683:
----------------------------------------

bq. I'm not sure what you mean exactly, we always end up calling it, we just 
don't check badness when it's set to zero.

I was a little confused on my last comment, but let me try again. Right now we 
only call {{sortByProximityWithScore()}} if {{BADNESS_THRESHOLD != 0}} and two 
neighbors in the list returned by the subsnitch differ by BADNESS_THRESHOLD.  I 
think it would make more sense (and fix Kirill's case) to always call 
{{sortByProximityWithScore()}} and then compare that ordering against the 
subsnitch list.  Something like this:

{noformat}
defaultOrder = subsnitch.sort(address, addresses);
scoredOrder = sortByProximityWithScore(address, addresses);  // make this 
return a new list instead of sorting in place
for (int i = 0; i < defaultOrder.size(); i++)
{
    if (scores.get(defaultOrder.get(i)) > scores.get(scoredOrder.get(i)) * (1 + 
BADNESS_THRESHOLD))
        return scoredOrder;
}
return defaultOrder;
{noformat}

bq. Possible, but it'd be a lot of work, because it would change the snitch 
interface and we'd still need the old call because not all uses of it have a 
consistency level available.

It looks like there aren't too many callers, so it shouldn't be that much work. 
 I would just make the arg optional and default it to the length of 
{{addresses}}.

> BADNESS_THRESHOLD does not working correctly with DynamicEndpointSnitch
> -----------------------------------------------------------------------
>
>                 Key: CASSANDRA-6683
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-6683
>             Project: Cassandra
>          Issue Type: Bug
>          Components: Core
>         Environment: Linux 3.8.0-33-generic
>            Reporter: Kirill Bogdanov
>              Labels: snitch
>             Fix For: 2.0.6
>
>
> There is a problem in *DynamicEndpointSnitch.java* in 
> sortByProximityWithBadness()
> Before calling sortByProximityWithScore we comparing each nodes score ratios 
> to the badness threshold.
> {code}
> if ((first - next) / first >  BADNESS_THRESHOLD)
>             {
>                 sortByProximityWithScore(address, addresses);
>                 return;
>             }
> {code}
> This is not always the correct comparison because *first* score can be less 
> than *next*  score and in that case we will compare a negative number with 
> positive.
> The solution is to compute absolute value of the ratio:
> {code}
> if (Math.abs((first - next) / first) > BADNESS_THRESHOLD)
> {code}
> This issue causing an incorrect sorting of DCs based on their performance and 
> affects performance of the snitch.
> Thanks.
>  



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Reply via email to