-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Token aware routing #824
Token aware routing #824
Conversation
e89e391
to
6da936e
Compare
shotover-proxy/src/transforms/cassandra/sink_cluster/routing/mod.rs
Outdated
Show resolved
Hide resolved
6da936e
to
671404d
Compare
shotover-proxy/src/transforms/cassandra/sink_cluster/node_pool.rs
Outdated
Show resolved
Hide resolved
shotover-proxy/src/transforms/cassandra/sink_cluster/node_pool.rs
Outdated
Show resolved
Hide resolved
shotover-proxy/src/transforms/cassandra/sink_cluster/node_pool.rs
Outdated
Show resolved
Hide resolved
shotover-proxy/src/transforms/cassandra/sink_cluster/node_pool.rs
Outdated
Show resolved
Hide resolved
386c0dc
to
30d754d
Compare
shotover-proxy/src/transforms/cassandra/sink_cluster/node_pool.rs
Outdated
Show resolved
Hide resolved
shotover-proxy/src/transforms/cassandra/sink_cluster/node_pool.rs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good so far mate, def need to think a bit more about how we make sure queries are prepped though
shotover-proxy/src/transforms/cassandra/sink_cluster/token_map.rs
Outdated
Show resolved
Hide resolved
shotover-proxy/src/transforms/cassandra/sink_cluster/token_map.rs
Outdated
Show resolved
Hide resolved
shotover-proxy/src/transforms/cassandra/sink_cluster/node_pool.rs
Outdated
Show resolved
Hide resolved
shotover-proxy/src/transforms/cassandra/sink_cluster/node_pool.rs
Outdated
Show resolved
Hide resolved
shotover-proxy/src/transforms/cassandra/sink_cluster/routing_key.rs
Outdated
Show resolved
Hide resolved
shotover-proxy/src/transforms/cassandra/sink_cluster/node_pool.rs
Outdated
Show resolved
Hide resolved
shotover-proxy/src/transforms/cassandra/sink_cluster/token_map.rs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I havent thoroughly reviewed the copy/pasted code because the plan is to upstream most of it back to cassandra-protocol.
But the rest all looks good to me!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one mate. This is an important bit of functionality!
We have a bit to clean up and work on, but just wanted to say great work!
Token Aware Routing
Changes
NodePool
TokenMap
routing_key
NodePool
andTokenMap
return the correct nodesToken aware routing workflow
Client sends a
PREPARE
statement to Shotover, we forward this to all nodes.Drivers typically send a
PREPARE
statement to one node. If it tries to use anEXECUTE
statement on a node that doesn't have the query prepared it will re-prepare on that node before sending theEXECUTE
statement again. The problem with this on Shotover is that we don't know which node returned the unprepared error, so we don't know which one we should be sending the re-prepared statement to. By preparing on all nodes, we can avoid this. If a node is added and it returns an unprepared error, the driver will re-prepare it again and Shotover will forward that to all nodes.Cache the metadata from the
PREPARED
result to aPREPARE
statementWe need to store this information to calculate the routing key to subsequent
EXECUTE
statements. Uses the prepared metadata id field as a key.Perform token aware routing on
EXECUTE
statementsUsing the prepared metadata, calculate the routing key and then the Murmur3 token. If a replica doesn't exist just perform random routing.
Followup
frame
method on every message and instead checking the opcode bytes directly first.