-
Notifications
You must be signed in to change notification settings - Fork 173
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
RUST-1571 Update ServerId to be int64 #894
Conversation
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.
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, |
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'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?
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 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.
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 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.
src/cmap/conn/mod.rs
Outdated
@@ -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. |
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.
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.
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.
LGTM!
Co-authored-by: Isabel Atkinson <isabelatkinson@gmail.com>
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.