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

Add information about server application version to metadata #1307

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

muzarski
Copy link
Contributor

@muzarski muzarski commented Apr 2, 2025

Fixes: #1286

This PR adds server application version information to the metadata.

It is exposed in two places:

  1. Node struct - a server version of specific node (release_version from system.local/system.peers)
  2. ClusterState - a cluster version, which is the version of the node currently used for control connection (release_version from system.local)

I'm not entirely sure about the second place. Maybe it's not really needed. I added some context to the corresponding commit message, so we can discuss this.

I implemented the test which validates the version for Scylla. It's possible, because Scylla currently hardcodes the release_version column to 3.0.8 and it does not seem like it's going to be addressed in the near future (the reason is some java-driver compatibility issues).

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.

muzarski added 4 commits April 2, 2025 17:53
This is the server version used by the Scylla/C* node.
This is a non-breaking change, because `Peer` is non_exhaustive.
This is a non-breaking change, because `Node` already has some private fields.

I decided not to include `server_version` in `PeerEndpoint` to avoid needless
cloning.

To obtain the server_version from `Peer`, one can use `Peer::into_peer_endpoint_tokens_and_server_version()`.
This consumes the `Peer` and moves the `server_version` to the caller.
In cpp-driver, `cass_schema_meta_version` returns the output
of `release_version` column from `system.local` query executed on
current control connection.

I'm not entirely sure if we should expose such API. `ClusterState::get_nodes_info()`
would be enough to implement in on the cpp-driver side - we would just choose
the version of random/first node. Or maybe return an error if there is a version
mismatch (?). This can be discussed.

The main thing I hate about this commit is this ugly `fold` expression
in `query_peers_and_cluster_version`. I have no idea if there is any
cleaner solution to this.
Copy link

github-actions bot commented Apr 2, 2025

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

@muzarski muzarski force-pushed the server-release-version branch from d436fa7 to 7fd38dc Compare April 2, 2025 16:03
@muzarski muzarski added this to the 1.1.0 milestone Apr 2, 2025
@muzarski muzarski self-assigned this Apr 2, 2025
@muzarski muzarski requested review from Lorak-mmk and wprzytula and removed request for Lorak-mmk April 2, 2025 16:16
@Lorak-mmk Lorak-mmk modified the milestones: 1.1.0, 1.2.0 Apr 3, 2025
Copy link
Collaborator

@Lorak-mmk Lorak-mmk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not review the code carefully yet, this is just a general comment.

I think that having the version in ClusterState too (so not only in Node) makes sense, because it makes the field much better to use. One change I'd do in this regard is putting a comment saying that the semantic of this field may change in the future, for example we may:

  • Use None if not all nodes have the same version
  • Concat versions if not all are the same to represent cluster that is being upgraded.

This PR makes sense for Cassandra, and for cpp-rust-driver, but is not very useful for Scylla users, who are our primary target.

Maybe we could expose Scylla version in ClusterState too?
I see that it is available for local node in system.versions (table existing only on Scylla).
We would need to make sure that this table is stable enough to be used in the driver (cc @piodul ).

Comment on lines +1016 to +1054
/// This test will work only for Scylla, as currently `release_version`
/// column always contains '3.0.8' value.
/// See: https://github.com/scylladb/scylladb/issues/8740
#[cfg_attr(cassandra_tests, ignore)]
#[tokio::test]
async fn test_metadata_scylla_release_version() {
setup_tracing();

let session = create_new_session_builder().build().await.unwrap();
let hardcoded_scylla_version = "3.0.8";

// Get release_version manually.
let release_version = session
.query_unpaged(
"SELECT release_version FROM system.local WHERE key='local'",
&[],
)
.await
.unwrap()
.into_rows_result()
.unwrap()
.single_row::<(String,)>()
.unwrap()
.0;
assert_eq!(&release_version, hardcoded_scylla_version);

let cluster_state = session.get_cluster_state();

let cluster_version = cluster_state.cluster_version().unwrap();
assert_eq!(cluster_version, hardcoded_scylla_version);

for node in cluster_state.get_nodes_info() {
assert_eq!(
node.server_version.as_deref(),
Some(hardcoded_scylla_version)
);
}
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can make this test work with C* too by getting rid of hardcoded version and using the result of manuala select as the source of truth.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True! I'll do that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add server release version info to metadata
2 participants