Skip to content

RUST-332 Return an error for replica set name mismatch #648

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

Merged
merged 5 commits into from
May 16, 2022

Conversation

abr-egn
Copy link
Contributor

@abr-egn abr-egn commented Apr 29, 2022

RUST-332 / RUST-358

This causes servers that don't match the repl set name given in the connection string to be marked as unknown, so any operation will return an error.

)
)?;
let opts = &self.common.options;
if let (Some(true), Some(set_name), Some(sel_server)) =
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This would be way easier to write and read if https://rust-lang.github.io/rfcs/2497-if-let-chains.html was implemented :(

options.hosts.drain(1..);
options.direct_connection = Some(true);
options.repl_set_name = Some("invalid".to_string());
let client = Client::with_options(options)?;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This needs to be a Client rather than a TestClient because the latter executes a few operations with unwrap()s, which fail and crash before the test can check anything.

@kmahar
Copy link
Contributor

kmahar commented Apr 29, 2022

I'm sorry we didn't discover this sooner, but I just went to look at the relevant section in the SDAM spec and noticed the language referenced in the ticket has now changed to:

A client MAY allow the user to supply a setName with an initial TopologyType of Single. In this case, if the ServerDescription's setName is null or wrong, the ServerDescription MUST be replaced with a default ServerDescription of type Unknown.

It looks like shortly after RUST-332 was filed, DRIVERS-980 got filed which resulted in the language being changed. The relevant Rust ticket spun out from that is RUST-358. So I think we'll want to adopt the newer behavior here instead.

As an aside, this is probably going to cause merge conflicts with #628 so we should keep that in mind for whichever of these PRs gets merged in later

@abr-egn abr-egn marked this pull request as draft May 2, 2022 14:15
@abr-egn
Copy link
Contributor Author

abr-egn commented May 2, 2022

It looks like shortly after RUST-332 was filed, DRIVERS-980 got filed which resulted in the language being changed. The relevant Rust ticket spun out from that is RUST-358. So I think we'll want to adopt the newer behavior here instead.

Whoops, missed that. Shouldn't be too hard to update to follow that.

@abr-egn abr-egn force-pushed the RUST-332/invalid-name branch from 8c11f49 to 39463c1 Compare May 4, 2022 16:07
@abr-egn abr-egn marked this pull request as ready for review May 4, 2022 19:30
Copy link
Contributor

@patrickfreed patrickfreed left a comment

Choose a reason for hiding this comment

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

LGTM!

@abr-egn abr-egn merged commit b555b17 into mongodb:main May 16, 2022
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.

4 participants