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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/cmap/conn/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,15 @@ pub struct ConnectionInfo {

/// 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.
/// If the connection ID sent by the server is too large for an i32, this will be a truncated
/// value.
pub server_id: Option<i32>,

/// 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. This
/// value will not be truncated and should be used rather than `server_id`.
pub server_id_i64: Option<i64>,

/// The address that the connection is connected to.
pub address: ServerAddress,
}
Expand All @@ -60,7 +67,7 @@ pub(crate) struct Connection {
/// Driver-generated ID for the connection.
pub(super) id: u32,
/// Server-generated ID for the connection.
pub(crate) server_id: Option<i32>,
pub(crate) server_id: Option<i64>,

pub(crate) address: ServerAddress,
pub(crate) generation: ConnectionGeneration,
Expand Down Expand Up @@ -165,7 +172,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.

server_id: self.server_id.map(|value| value as i32),
server_id_i64: self.server_id,
address: self.address.clone(),
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/hello.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ pub(crate) struct HelloCommandResponse {

/// The server-generated ID for the connection the "hello" command was run on.
/// Present on server versions 4.2+.
pub connection_id: Option<i32>,
pub connection_id: Option<i64>,
}

impl HelloCommandResponse {
Expand Down