Skip to content

RUST-122 Support mongos pinning for sharded transactions #383

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 16 commits into from
Jul 19, 2021

Conversation

NBSquare
Copy link
Contributor

@NBSquare NBSquare commented Jul 1, 2021

Implemented mongos pinning on sharded transactions.

Important notes:

  • Because recovery token hasn't been implemented, there are a few places where the field is expected or a related error is raised. In order to test the desired functionality for this PR, these issues have been suppressed, along with TODO comments for RUST-97 (implement recovery tokens).
  • src/test/spec/json/transactions has a number of V2 runner tests which are related to pinning, and these are being skipped through a simple check in test::spec::transactions::run. Removing this check would cause recovery token tests to fail. Rather than remove these, I created another method test::spec::transactions::test_sharded_transactions which runs a subset of these V2 tests, as well as the unpin test for the unified runner.

@NBSquare NBSquare requested review from patrickfreed, isabelatkinson and abr-egn and removed request for patrickfreed and abr-egn July 1, 2021 18:11
@NBSquare
Copy link
Contributor Author

NBSquare commented Jul 1, 2021

Removing Patrick and Abraham until Isabel gets a chance to look at this.

@@ -285,6 +298,9 @@ impl ClientSession {
}
.into());
}
TransactionState::Committed { .. } => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it necessary to have this here given that we are unpinning the session at the beginning of execute_operation_with_retry?

Copy link
Contributor Author

@NBSquare NBSquare Jul 7, 2021

Choose a reason for hiding this comment

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

I think so. Per the spec, we want to unpin the session when:

A new transaction is started on the ClientSession after the previous transaction has been committed. The session MUST be unpinned before performing server selection for the first operation of the new transaction.

Because start_transaction doesn't execute an operation but changes the transaction state to Starting we want to make sure the session is unpinned, so server selection is performed normally when the first operation on the transaction is executed.

@durran
Copy link
Member

durran commented Jul 9, 2021

I'm not familiar with the Rust driver's design but just wanted to chime in with a note that could make everyone's lives easier in the future. When implementing load balancer support, the driver will need to be able to pin connections as well, to both cursors and transactions. So may be something to think about now when the pinning related functionality for mongos goes in. Hope that information may help if no one had it yet.

@NBSquare NBSquare force-pushed the RUST-122 branch 4 times, most recently from 9351a6d to d369d42 Compare July 13, 2021 20:48
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.

one small comment but otherwise this looks great! also it looks like changes from some newer commits on master are being shown in the diff for this PR, can you update the branch to include these commits as well to fix?

None => None,
};
// TODO RUST-900: Remove this extraneous call.
if test.operations.iter().any(|op| op.name == "distinct") {
Copy link
Contributor

Choose a reason for hiding this comment

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

As a slight optimization, we can also add conditions here only to run distinct on each host when we're working with a 4.2 sharded cluster, as that's the only topology where we run into this issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That sounds good. As an aside, some of the other drivers have also run into issues related to StaleDbVersion on other versions. However, it sounds like these bugs are weird and driver-specific.

Since we only ran into the issue on 4.2 sharded, I think it makes sense to add this check, but I want to draw attention to the fact that the issue has impacted other versions on other drivers.

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.

Just one question from me, going to tag in the rest of the team for review. Can you run a full evg patch (i.e. all the variants prefixed with !) and add a link to it on the ticket? (Note to reviewers: evergreen patches aren't running automatically because this PR is on a separate branch. Patches are linked in the comments on RUST-122.)

@NBSquare NBSquare changed the base branch from sharded-transactions to master July 15, 2021 18:23
@NBSquare NBSquare changed the base branch from master to sharded-transactions July 15, 2021 18: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!

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.

I have a few minor suggestions, but otherwise looks good!

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.

Looks really good, just have one minor suggestion

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! great job with this

@NBSquare NBSquare merged commit 349bc6a into mongodb:sharded-transactions Jul 19, 2021
@NBSquare NBSquare deleted the RUST-122 branch July 19, 2021 20:56
NBSquare added a commit to NBSquare/mongo-rust-driver that referenced this pull request Jul 21, 2021
NBSquare added a commit to NBSquare/mongo-rust-driver that referenced this pull request Jul 26, 2021
NBSquare added a commit to NBSquare/mongo-rust-driver that referenced this pull request Jul 27, 2021
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.

5 participants