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

RUST-1571 Update ServerId to be int64 #894

Merged
merged 4 commits into from
Jun 14, 2023
Merged

RUST-1571 Update ServerId to be int64 #894

merged 4 commits into from
Jun 14, 2023

Conversation

drshika
Copy link
Contributor

@drshika drshika commented Jun 12, 2023

ServerId is assigned to ConnectionId here: https://github.com/mongodb/mongo-rust-driver/blob/main/src/cmap/establish/handshake/mod.rs#L457. To fix the int32 overflow issue, I added a new ServerId int64 value.

@drshika drshika requested a review from abr-egn June 12, 2023 19:55
@abr-egn abr-egn requested a review from isabelatkinson June 13, 2023 14:12
Copy link
Contributor

@abr-egn abr-egn left a comment

Choose a reason for hiding this comment

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

Looks good! Waiting to see what Isabel's thoughts are before giving the official stamp.

@@ -165,7 +171,8 @@ impl Connection {
pub(crate) fn info(&self) -> ConnectionInfo {
ConnectionInfo {
id: self.id,
server_id: self.server_id,
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm of two minds here whether truncation or omission is better when the server_id doesn't fit in an i32. @isabelatkinson do you have an opinion here?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be a breaking/unexpected change for users who are currently relying on this field to be Some (even if it's a truncated value) to stop populating it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree with Isabel. The i64 overflow issue affects a small amount of users and would bother more users if we just removed support for the original server_id without warning.

@@ -46,9 +46,15 @@ pub struct ConnectionInfo {
pub id: u32,

/// A server-generated identifier that uniquely identifies the connection. Available on server
/// versions 4.2+. This may be used to correlate driver connections with server logs.
/// versions 4.2+. This may be used to correlate driver connections with server logs. This
/// could be a truncated value based on input server_id.
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: how about "If the connection ID sent by the server is too large for an i32, this will be a truncated value." (or "will be None." if we go the other way) for wording? I think it's useful for our users when we can be more precise about the behavior.

@drshika drshika requested a review from abr-egn June 13, 2023 15:23
Copy link
Contributor

@abr-egn abr-egn left a comment

Choose a reason for hiding this comment

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

LGTM!

Co-authored-by: Isabel Atkinson <isabelatkinson@gmail.com>
@drshika drshika requested a review from isabelatkinson June 13, 2023 20:52
@drshika drshika merged commit acbe2ba into mongodb:main Jun 14, 2023
@drshika drshika deleted the RUST-1571/ConnectionId-may-be-int64 branch June 14, 2023 01:33
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.

3 participants