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

Stefan Miklosovic commented on CASSANDRA-19426:
-----------------------------------------------

in maybeGossipToSeed, this 

{noformat}
double probability = seeds.size() / (double) (liveEndpoints.size() + 
unreachableEndpoints.size());
{noformat}

will never be Infinity, because liveEndoints.size() will not be 0. If it was, 
we would never came to that "else" branch.

If we have this in maybeGossipToCMS

{noformat}
        Set<InetAddressAndPort> cms = 
ClusterMetadata.current().fullCMSMembers();
        if (cms.contains(getBroadcastAddressAndPort()))
            return;

        double probability = cms.size() / (double) (liveEndpoints.size() + 
unreachableEndpoints.size());
{noformat}

cms set can be e.g. 2 nodes, if cms does not contain the current node, then 
liveEndpoints will be non-zero too, no? In other words, can cms members be "not 
live" ? If they are not live, then they will be unreachable, so that will again 
not produce Infinity there.

I am still returning to this but I just can not see how it might be Infinity. 
Both liveEndpoints and unreachableEndpoints would have to be 0. Under what 
scenario that would be true?

> Fix Double Type issues in the Gossiper#maybeGossipToCMS
> -------------------------------------------------------
>
>                 Key: CASSANDRA-19426
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-19426
>             Project: Cassandra
>          Issue Type: Improvement
>          Components: Cluster/Gossip, Transactional Cluster Metadata
>            Reporter: Ling Mao
>            Assignee: Ling Mao
>            Priority: Low
>             Fix For: 5.x
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> _*issue-1:*_
> if liveEndpoints.size()=unreachableEndpoints.size()=0; probability will be 
> {*}_Infinity_{*}.
> randDbl <= probability will always be true, then sendGossip
> _*issue-2:*_ 
> comparing two double is safe by using *<* or {*}>{*}. However missing 
> accuracy will happen if we compare the equality of two double by 
> intuition({*}={*}). For example:
> {code:java}
> double probability = 0.1;
> double randDbl = 0.10000000000000001; // Slightly greater than probability
> if (randDbl <= probability)
> {
>     System.out.println("randDbl <= probability(always here)");
> }
> else
> {
>     System.out.println("randDbl > probability");
> }
> {code}
> A good example from: _*Gossiper#maybeGossipToUnreachableMember*_
> {code:java}
> if (randDbl < prob)
> {
> sendGossip(message, Sets.filter(unreachableEndpoints.keySet(),
>                                 ep -> 
> !isDeadState(getEndpointStateMap().get(ep))));
> }{code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org

Reply via email to