-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Direct retries to another mongos if one is available #1367
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
Implemented the change and unit tests JAVA-4254, JAVA-5320
JAVA-4254, JAVA-5320
JAVA-4254, JAVA-5320
JAVA-4254, JAVA-5320
driver-core/src/main/com/mongodb/internal/connection/OperationContext.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/internal/operation/AsyncOperationHelper.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/internal/connection/OperationContext.java
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/internal/connection/OperationContext.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/internal/connection/BaseCluster.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/internal/connection/BaseCluster.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/internal/connection/OperationContext.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/internal/connection/OperationContext.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/internal/connection/OperationContext.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/internal/connection/OperationContext.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/internal/connection/OperationContext.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/internal/operation/AsyncOperationHelper.java
Outdated
Show resolved
Hide resolved
…Context.java Let's put various checks (validation, preconditions...) at the top of methods, with the operation at the bottom. Co-authored-by: Maxim Katcharov <[email protected]>
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!
JAVA-4254
… side effects JAVA-4254
…tion The new approach allows us to later refactor all other logic inside one or more `ServerSelector`s. See the comment left in the code for more details on the new approach. JAVA-4254
…verSelector` JAVA-4254
…uirements JAVA-4254
JAVA-4254
driver-core/src/main/com/mongodb/internal/connection/BaseCluster.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/internal/connection/BaseCluster.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/internal/connection/BaseCluster.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/internal/connection/BaseCluster.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/internal/selector/OperationCountMinimizingServerSelector.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/internal/connection/OperationContext.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/internal/connection/OperationContext.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/internal/connection/OperationContext.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/internal/connection/OperationContext.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/internal/operation/AsyncOperationHelper.java
Outdated
Show resolved
Hide resolved
JAVA-4254
… the two last lines of the corresponding comment, as they are not informative. JAVA-4254
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.
LGTM, just one optional suggestion
Given that the current specification wording is internally inconsistent, I confirmed the actual intent with the spec author and created DRIVERS-2901 Clarify the intent behind the list of deprioritized mongos'es and fix the pseudocode.
Performance considerations
Our
ServerSelector
andClusterDescription
API do not allow us to implement an efficient pipeline (CompositeServerSelector
) ofServerSelector
s: we can neither mutate theList<ServerDescription>
in place, nor mutateClusterDescription
, nor even reuse the sameClusterDescription
if a selector did not filter anything out. This PR added one more selector required by the specification logic, and introduced two more selectors by refactoring server selection code that wasn't expressed in terms ofServerSelector
s. As a result, it is conceivable that the PR has negative performance impact.Additionally, due to this refactoring d25010d, each server selection iteration now involves copying the map of
Server
s maintained by aCluster
. While that copying does not entail locking (all hail the CHM!), it may still have additional negative performance impact.If we indeed notice performance degradation, we may try mitigating the issue by introducing
InternalServerSelector extends ServerSelector
(or a subclass ofClusterDescription
that allows mutatinggetServerDescriptions
, or both), which allows for a more optimal chaining, and use it for everything but the application-specific selector. This is assuming, of course, that the would be degradation is caused to a large extent by the inefficient selector chaining, and not by the CHM copying.JAVA-4254, JAVA-5320