Skip to content

RUST-2125 Run tests using LB URI when present #1279

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 9 commits into from
Jan 14, 2025

Conversation

abr-egn
Copy link
Contributor

@abr-egn abr-egn commented Jan 8, 2025

RUST-2125

Turns out we were, in fact, not running the driver test suite in loadbalanced mode. This run shows a test properly failing with a pinning error with this fix in place and the earlier bugfix to the pinning logic reverted.

.client
.pin_connection_for_cursor(&specification, context.connection)?;

let pinned_connection = self.client.pin_connection_for_cursor(
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 was a distinct bug from RUST-2131, where the original code should have been conditionally using pin_connection_for_session when a session was present; not doing so caused tests of bulk write on load balancer running inside a transaction to fail with an internal "already pinned" error. I merged the two pin_connection_for_* methods to prevent this kind of easy mistake in the future and make it easier to reason about exactly when a connection for a cursor gets pinned.

Copy link
Contributor

Choose a reason for hiding this comment

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

good catch! combining the pinning methods makes sense

@@ -78,7 +78,7 @@ impl TestOperation for AssertSessionPinned {
async move {
let is_pinned =
with_mut_session!(test_runner, self.session.as_str(), |session| async {
session.transaction.pinned_mongos().is_some()
session.transaction.is_pinned()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also a distinct bug, just missing that there are now more cases than pinned_mongos :)

self.id
))
})?;
let mut connection = match receiver.try_recv() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using try_recv rather than recv means the re-entrant case becomes an error rather than a deadlock, which seems much better behavior to me. The hypothetical downside is that it could fail in a race condition, but since any individual pinned connection is used in a strictly linear sequence that doesn't apply here.

@abr-egn abr-egn marked this pull request as ready for review January 10, 2025 20:38
Copy link
Contributor

@isabelatkinson isabelatkinson left a comment

Choose a reason for hiding this comment

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

tiny doc fix, otherwise looks good!

.client
.pin_connection_for_cursor(&specification, context.connection)?;

let pinned_connection = self.client.pin_connection_for_cursor(
Copy link
Contributor

Choose a reason for hiding this comment

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

good catch! combining the pinning methods makes sense

Co-authored-by: Isabel Atkinson <isabelatkinson@gmail.com>
@abr-egn abr-egn merged commit cb7fbd5 into mongodb:main Jan 14, 2025
1 check was pending
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.

2 participants