You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Michael Semb Wever (Jira)" <ji...@apache.org> on 2026/08/26 12:39:00 UTC

[jira] [Created] (CASSANDRA-21608) Data race in token allocation can throw a NullPointerException

Michael Semb Wever created CASSANDRA-21608:
----------------------------------------------

             Summary: Data race in token allocation can throw a NullPointerException
                 Key: CASSANDRA-21608
                 URL: https://issues.apache.org/jira/browse/CASSANDRA-21608
             Project: Apache Cassandra
          Issue Type: Bug
          Components: Cluster/Membership
            Reporter: Michael Semb Wever
            Assignee: Michael Semb Wever


{{TokenAllocation.adjustForCrossDatacenterClashes}} reads {{tokenMetadata.getEndpoint(t)}} twice: once for the loop condition and once in the loop body.

{code:java}
while (tokenMetadata.getEndpoint(t) != null)
{
    InetAddressAndPort other = tokenMetadata.getEndpoint(t);
    if (inAllocationRing(other))
        throw new ConfigurationException(...);
    t = t.nextValidToken();
}
{code}

A ring change between the two reads removes the endpoint. The body then sees null and {{inAllocationRing(other)}} throws a NullPointerException, which fails token allocation on a bootstrapping node.

The patch reads the endpoint once into a local variable and tests that value.

Provenance: the change comes from the DataStax fork of Cassandra, commit {{e07e7805b5}} (fork ticket CNDB-11134), by the original author Michael Marshall. Local branch: {{mck/upstream/token-allocation-race/5.0}}, based on {{cassandra-5.0}}.



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

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