Empty TokenRange returned in a one token cluster

Description

When calling getTokenRanges() on a one node cluster, where the single node has only one token, if that token is not the minimum token, the returned range from getTokenRanges is an empty range. This is because the start token is the same as the end token, but they are not the minimum token.

Later, when attempting to do a range query, no data is returned, because instead of representing the whole ring, this range represents only an empty range. The thrift code internal to Cassandra handled this by computing isWrappedAround() as start.compareTo(end) >= 0, instead of start.compareTo(end) > 0. Another possible solution is to return two ranges in the one token edge case, [min token, start ) and [start, min token). Other solutions probably exist.

Environment

None

Pull Requests

None

Activity

Show:
Olivier Michallat
March 10, 2015, 8:44 AM

Good catch.
The reasons for considering ]x,x], x!=minToken as empty is that you could get such a range out of a split operation (in edge cases where there are less token values than the requested number of splits). We wouldn't want to split a very small range and end up with the whole ring.
Also, this matches the behavior of CQL range queries:

with Murmur3Partitioner

So I think the solution is to have a special case when we compute the token ranges for the cluster: if there is only one token, return the range ]minToken, minToken].

Fixed

Assignee

Andy Tolbert

Reporter

Philip Thompson

Labels

None

PM Priority

None

Reproduced in

2.1.5

Affects versions

Fix versions

Pull Request

None

Doc Impact

None

Size

None

External issue ID

None

External issue ID

None

Components

Priority

Major
Configure