Skip to content

4.x: Do not expose NodeShardingInfo via Node #486

Open
@scrat98

Description

@scrat98

With ScyllaDB Tablets enabled by default, it is no longer possible to use a consistent algorithm to map a Token to a ShardId. This is because a Tablet (which holds a set of tokens) can migrate between shards within the same node or even across nodes for load balancing.

CqlRequestHandler correctly relies on the TabletMap(getShardFromTabletMap) https://github.com/scylladb/java-driver/blob/scylla-4.x/core/src/main/java/com/datastax/oss/driver/internal/core/cql/CqlRequestHandler.java#L369

But obtaining shardId via Node still relies on the calculation: https://github.com/scylladb/java-driver/blob/scylla-4.x/core/src/main/java/com/datastax/oss/driver/internal/core/protocol/ShardingInfo.java#L66
And users can still use Node.getShardingInfo().getShardId(token) for grouping the statements for example, like here #232

Even with Tablets disabled, mapping a Token to a ShardId is not feasible because there is no predictable relationship between ShardId and a specific CPU. Each node manages its shards independently (and that mappings may be changes after restart, for example) and does not rely on consistent hashing of token ranges. https://opensource.docs.scylladb.com/stable/kb/map-cpu.html

To avoid users confusion and mistakes I would suggest deprecate this method and mark it as for removal. In the driver source code everything uses TabletMap already and not rely on the Node.getShardId

Note: According to the protocol documentation "biased-token-round-robin" algorithm should still work, but I'm not sure if it's updated or not, because then I can't understand how it should work with Tablets. Therefore, I'm sorry in advance if my knowledge about scylla is wrong and all the statements above as well https://github.com/scylladb/scylladb/blob/master/docs/dev/protocol-extensions.md#intranode-sharding

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions