scylladb/scylla-rust-driver

Support token aware routing for cassandra

Closed this issue · 1 comments

I was reading the source code and stumbled upon this logic for routing with no sharding:

Self::choose_random_connection_from_slice(conns).unwrap()

And this logic for parsing sharding info from a supported response:
fn try_from(options: &'a HashMap<String, Vec<String>>) -> Result<Self, Self::Error> {

My understanding of this is that scylla-rust-driver will silently never perform token aware routing for cassandra because cassandra does not support sharding.
It should be straightforward to add support for cassandra here by considering each cassandra instance to be a single shard?

Edit: thinking about this more I already rely on scylla-rust-drivers cassandra token aware routing support (see #681 )
So I'm probably misunderstanding something in the code, I'll investigate further myself.

Looking at the TRACE level logs, token aware routing is clearly happening for cassandra.
It seems that the filtering of connections happens at an earlier stage.
Sorry for the poor issue.

edit: figured it out.
token aware routing happens at the node level instead of at the connection pool level (each node has its own connection pool)
This is where the logic for token aware routing lives https://github.com/scylladb/scylla-rust-driver/blob/main/scylla/src/transport/locator/mod.rs