-
Notifications
You must be signed in to change notification settings - Fork 180
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
Conversation
Removing Patrick and Abraham until Isabel gets a chance to look at this. |
@@ -285,6 +298,9 @@ impl ClientSession { | |||
} | |||
.into()); | |||
} | |||
TransactionState::Committed { .. } => { |
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.
Is it necessary to have this here given that we are unpinning the session at the beginning of execute_operation_with_retry
?
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 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.
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. |
9351a6d
to
d369d42
Compare
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.
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?
src/test/spec/v2_runner/mod.rs
Outdated
None => None, | ||
}; | ||
// TODO RUST-900: Remove this extraneous call. | ||
if test.operations.iter().any(|op| op.name == "distinct") { |
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.
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.
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.
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.
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.
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.)
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!
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 have a few minor suggestions, but otherwise looks good!
src/test/spec/json/sharded-transactions/mongos-pin-auto-tests.py
Outdated
Show resolved
Hide resolved
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 really good, just have one minor suggestion
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! great job with this
Implemented
mongos
pinning on sharded transactions.Important notes:
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 intest::spec::transactions::run
. Removing this check would cause recovery token tests to fail. Rather than remove these, I created another methodtest::spec::transactions::test_sharded_transactions
which runs a subset of these V2 tests, as well as the unpin test for the unified runner.