Skip to content
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

Expose request coordinator #1287

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

wprzytula
Copy link
Collaborator

@wprzytula wprzytula commented Mar 20, 2025

This draft is the first attempt to implement #1030. For now, only address is exposed; host ID is not, as it's not accessible in Connection (yet?).

Fixes: #1030

Pre-review checklist

  • I have split my patch into logically separate commits.
  • All commit messages clearly explain what they change and why.
  • I added relevant tests for new features and bug fixes.
  • All commits compile, pass static checks and pass test.
  • PR description sums up the changes and reasons why they should be introduced.
  • I have provided docstrings for the public items that I want to introduce.
  • I have adjusted the documentation in ./docs/source/.
  • I added appropriate Fixes: annotations to PR description.

It was a leftover from the deserialization refactor.
@wprzytula wprzytula requested review from muzarski and Lorak-mmk March 20, 2025 07:46
@wprzytula wprzytula added this to the 1.1.0 milestone Mar 20, 2025
@wprzytula wprzytula added cpp-rust-driver-p1 Functionality required by cpp-rust-driver QoL Quality of Life enhancements labels Mar 20, 2025
Copy link

github-actions bot commented Mar 20, 2025

cargo semver-checks found no API-breaking changes in this PR.
Checked commit: c2860f5

@wprzytula wprzytula force-pushed the store-request-coordinator branch from 7a45481 to c2860f5 Compare March 20, 2025 07:49
@Lorak-mmk
Copy link
Collaborator

Why did you introduce new struct (Coordinator) instead of using Node?

@wprzytula
Copy link
Collaborator Author

Why did you introduce new struct (Coordinator) instead of using Node?

  1. I did not realise that we do have access to Node in all places where we need to create Coordinator -- this fortunately seems to be true.
  2. Coordinator is not a struct. It's just a type alias that is used for convenience. I imagined it could be a pair (Uuid, SocketAddr) in the final version of this PR.

@muzarski
Copy link
Contributor

Why did you introduce new struct (Coordinator) instead of using Node?

Just Node is not enough for cpp-rust-driver purposes. In cpp-driver, the coordinator is the target (i.e. node + shard) identified by SocketAddr.

@Lorak-mmk
Copy link
Collaborator

Why did you introduce new struct (Coordinator) instead of using Node?

Just Node is not enough for cpp-rust-driver purposes. In cpp-driver, the coordinator is the target (i.e. node + shard) identified by SocketAddr.

Is there really an API in cpp-driver to retrieve a shard that the request was sent to?

@muzarski
Copy link
Contributor

Why did you introduce new struct (Coordinator) instead of using Node?

Just Node is not enough for cpp-rust-driver purposes. In cpp-driver, the coordinator is the target (i.e. node + shard) identified by SocketAddr.

Is there really an API in cpp-driver to retrieve a shard that the request was sent to?

No, I might have phrased it wrong. Now that I think of it, I did, because there are no shards in Cassandra. What I meant is just that the request coordinator is identified via ip + port (SocketAddr).

@Lorak-mmk
Copy link
Collaborator

What I meant is just that the request coordinator is identified via ip + port (SocketAddr).

Than I don't understand why Node is not enough. It has addr field which contains SocketAddr inside: https://docs.rs/scylla/latest/scylla/cluster/enum.NodeAddr.html

@Lorak-mmk
Copy link
Collaborator

We can of course consider wrapping Node (or whatever else we need) in a new Coordinator struct if we may want to add new stuff there (maybe a Option?).

@muzarski
Copy link
Contributor

What I meant is just that the request coordinator is identified via ip + port (SocketAddr).

Than I don't understand why Node is not enough. It has addr field which contains SocketAddr inside: https://docs.rs/scylla/latest/scylla/cluster/enum.NodeAddr.html

But the port in this SocketAddr is not always the port of the connection we routed the request to. AFAIU, this port is set to self.control_connection_endpoint.address().port() obtained here: https://github.com/scylladb/scylla-rust-driver/blob/v1.0.0/scylla/src/cluster/metadata.rs#L608. This port is later propagated for other peers as well (is it even correct???). Notice that the queried rpc_address from system.local/peers is an ip address without any port information.

@wprzytula
Copy link
Collaborator Author

: https://github.com/scylladb/scylla-rust-driver/blob/v1.0.0/scylla/src/cluster/metadata.rs#L608. This port is later propagated for other peers as well (is it even correct???).

Thanks for spotting the bug!

@wprzytula
Copy link
Collaborator Author

This port is later propagated for other peers as well (is it even correct???).

I took a blame walk and this is what I found:
image

@Lorak-mmk
Copy link
Collaborator

: https://github.com/scylladb/scylla-rust-driver/blob/v1.0.0/scylla/src/cluster/metadata.rs#L608. This port is later propagated for other peers as well (is it even correct???).

Thanks for spotting the bug!

Is it a bug?

@wprzytula
Copy link
Collaborator Author

: https://github.com/scylladb/scylla-rust-driver/blob/v1.0.0/scylla/src/cluster/metadata.rs#L608. This port is later propagated for other peers as well (is it even correct???).

Thanks for spotting the bug!

Is it a bug?

Is it not? Is the assumption that all nodes in the cluster expose the same port correct?

@Lorak-mmk
Copy link
Collaborator

Lorak-mmk commented Mar 20, 2025

Is it not? Is the assumption that all nodes in the cluster expose the same port correct?

I don't know. If it is not, how can we discover other ports?

@wprzytula
Copy link
Collaborator Author

Is it not? Is the assumption that all nodes in the cluster expose the same port correct?

I don't know. If it is not, how can we discover other ports?

OK, so in an internal discussion we established that all nodes shall follow the same configuration, including the native_transport_port. Thus, this is not a bug.

@Lorak-mmk Lorak-mmk modified the milestones: 1.1.0, 1.2.0 Apr 3, 2025
@wprzytula
Copy link
Collaborator Author

Why did you introduce new struct (Coordinator) instead of using Node?

Node is not clonable. Arc<Node> is clonable quite cheaply, but not as cheaply as custom structs filled with a bunch of Copy types are. Therefore, I still believe a tuple (be it a named tuple or a struct) is a better fit here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cpp-rust-driver-p1 Functionality required by cpp-rust-driver QoL Quality of Life enhancements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose request coordinator id (host_id, address) in QueryResult
3 participants