-
Notifications
You must be signed in to change notification settings - Fork 434
[Store] add version checking between client and server #1061
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
base: main
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @stmatengss, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a critical version compatibility mechanism between the Mooncake client and server. It ensures that clients only connect to servers running a compatible version by performing an explicit version check during the connection establishment phase. This enhancement prevents potential runtime errors and unexpected behavior that could arise from mismatched client and server versions. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request introduces version checking between the client and server, which is a crucial feature for maintaining compatibility and stability. The implementation is straightforward, with the server exposing its version via an RPC endpoint that the client checks upon connection. My feedback includes a suggestion to improve the version checking logic for better flexibility in future releases and a minor performance optimization to avoid unnecessary string copies.
| std::string server_version = result.value(); | ||
| std::string client_version = GetMooncakeVersion(); | ||
| if (server_version != client_version) { | ||
| LOG(ERROR) << "Version mismatch: server=" << server_version | ||
| << " client=" << client_version; | ||
| timer.LogResponse("error_code=", ErrorCode::INVALID_VERSION); | ||
| return ErrorCode::INVALID_VERSION; | ||
| } |
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.
This version check implementation can be improved in two ways:
-
Performance:
result.value()andGetMooncakeVersion()both return references to strings, but they are being copied intoserver_versionandclient_version. You can avoid these unnecessary copies by usingconst std::string&. -
Flexibility: The current strict string comparison means any version change (even a patch for a bug fix) will be a breaking change, forcing all clients to upgrade. Consider implementing a more flexible check, like comparing only the major version number. This would allow for non-breaking updates on the server.
Here is a suggested implementation that addresses both points:
| std::string server_version = result.value(); | |
| std::string client_version = GetMooncakeVersion(); | |
| if (server_version != client_version) { | |
| LOG(ERROR) << "Version mismatch: server=" << server_version | |
| << " client=" << client_version; | |
| timer.LogResponse("error_code=", ErrorCode::INVALID_VERSION); | |
| return ErrorCode::INVALID_VERSION; | |
| } | |
| const std::string& server_version_str = result.value(); | |
| const std::string& client_version_str = GetMooncakeVersion(); | |
| // A simple way to check for major version compatibility. | |
| // For a more robust solution, consider a dedicated version parsing utility. | |
| auto get_major = [](const std::string& v_str) { | |
| return v_str.substr(0, v_str.find('.')); | |
| }; | |
| if (get_major(server_version_str) != get_major(client_version_str)) { | |
| LOG(ERROR) << "Version mismatch: server=" << server_version_str | |
| << " client=" << client_version_str; | |
| timer.LogResponse("error_code=", ErrorCode::INVALID_VERSION); | |
| return ErrorCode::INVALID_VERSION; | |
| } |
|
Thanks for the PR! I have two suggestions regarding the versioning logic:
|
1 similar comment
|
Thanks for the PR! I have two suggestions regarding the versioning logic:
|
c34ff19 to
36fecda
Compare
No description provided.