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

Stefania commented on CASSANDRA-12784:
--------------------------------------

{{testExistingCluster}} is not deterministic for random partitioner because:

{code}
    public BigIntegerToken getRandomToken(Random random)
    {
        BigInteger token = 
FBUtilities.hashToBigInteger(GuidGenerator.guidAsBytes(random));
        if ( token.signum() == -1 )
            token = token.multiply(BigInteger.valueOf(-1L));
        return new BigIntegerToken(token);
    }
{code}

and

{code}
    public static ByteBuffer guidAsBytes(Random random)
    {
        StringBuilder sbValueBeforeMD5 = new StringBuilder();
        long time = System.currentTimeMillis();
        long rand = 0;
        rand = random.nextLong();
        sbValueBeforeMD5.append(s_id)
                        .append(":")
                        .append(Long.toString(time))
                        .append(":")
                        .append(Long.toString(rand));

        String valueBeforeMD5 = sbValueBeforeMD5.toString();
        return 
ByteBuffer.wrap(FBUtilities.threadLocalMD5Digest().digest(valueBeforeMD5.getBytes()));
    }
{code}

There is a dependency on the current time. I've removed it in the latest 
[commit|https://github.com/stef1927/cassandra/commit/b6e39d1105df6f1845c2a3928b454339b0e21201]
 and launched all tests:

||3.X||trunk||
|[patch|https://github.com/stef1927/cassandra/tree/12784-3.X]|[patch|https://github.com/stef1927/cassandra/tree/12784]|
|[testall|http://cassci.datastax.com/view/Dev/view/stef1927/job/stef1927-12784-3.X-testall/]|[testall|http://cassci.datastax.com/view/Dev/view/stef1927/job/stef1927-12784-testall/]|
|[dtest|http://cassci.datastax.com/view/Dev/view/stef1927/job/stef1927-12784-3.X-dtest/]|[dtest|http://cassci.datastax.com/view/Dev/view/stef1927/job/stef1927-12784-dtest/]|

The only other caller of {{RandomPartitioner.getRandomToken(Random)}} is 
compaction-stress (CASSANDRA-11844), and the documentation of 
{{CompationStress.generateTokens()}} also indicates that this method should 
generate tokens in a deterministic way.

> ReplicationAwareTokenAllocatorTest times out almost every time for 3.X and 
> trunk
> --------------------------------------------------------------------------------
>
>                 Key: CASSANDRA-12784
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-12784
>             Project: Cassandra
>          Issue Type: Bug
>            Reporter: Stefania
>            Assignee: Stefania
>             Fix For: 3.x
>
>         Attachments: ReplicationAwareTokenAllocatorTest.jfr.gz
>
>
> Example failure: 
> http://cassci.datastax.com/view/cassandra-3.X/job/cassandra-3.X_testall/lastCompletedBuild/testReport/org.apache.cassandra.dht.tokenallocator/ReplicationAwareTokenAllocatorTest/testNewClusterWithMurmur3Partitioner/



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to