-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
CSOT #1215
Conversation
Initial client side operation timeout (CSOT) work. The CSOT class is passed to all operations and currently encapsulate the following timeouts: - `timeoutMS` the new optional client side operation timeout - `maxTimeMS` the legacy maxTimeMS operation value. Ignored if CSOT is set. - `maxCommitTimeMS` the legacy commit timeout. Ignored if CSOT is set. - `maxAwaitTimeMS` the getMore await timeout. This initial work allows for the CSOT to be available to all operations and later work will pass / apply this timeout where required by the Spec. JAVA-4086
# Conflicts: # driver-core/src/main/com/mongodb/ConnectionString.java # driver-core/src/test/unit/com/mongodb/MongoClientSettingsSpecification.groovy
An immutable class that contains all user configured timeouts. This will eventaually allow access to user configuration down the stack into Bindings / Cluster.selectServer and Connection.command. JAVA-5169
In preparation for adding all contexts to OperationContext JAVA-5170
This will allow the timeout settings to be available to the Binding and this will allow the binding to create the TimeoutContext for the operation. JAVA-5170
Now contains RequestContext, SessionContext and TimeoutContext JAVA-5170
Operations now supply TimeoutSettings JAVA-5170
Pass OperationContext as a whole instead of RequestContext, SessionContext, TimeoutContext and ServerAPI JAVA-5170
Adds support for Explainable operations JAVA-5172
# Conflicts: # driver-core/src/main/com/mongodb/internal/connection/BaseCluster.java # driver-core/src/main/com/mongodb/internal/connection/LoadBalancedCluster.java # driver-core/src/test/functional/com/mongodb/ClusterFixture.java # driver-core/src/test/unit/com/mongodb/internal/connection/BaseClusterSpecification.groovy # driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/ClientSessionBinding.java # driver-reactive-streams/src/test/unit/com/mongodb/reactivestreams/client/internal/ClientSessionBindingSpecification.groovy # driver-sync/src/test/unit/com/mongodb/client/internal/ClientSessionBindingSpecification.groovy
if (this == o) { | ||
return true; | ||
static Timeout expiresIn(final long duration, final TimeUnit unit) { | ||
// TODO (CSOT) confirm that all usages in final PR are non-negative |
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.
Note to address all TODOs prior to merging. (All files in github can be loaded using document.querySelectorAll('.load-diff-button').forEach(node => node.click())
in console, and then ctrl-f for TODO
)
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 addressed critical //TODO
comments.
JAVA-5379 * Remove usages of hasExpired * Replace RetryState's timeout with retryUntilTimeoutThrowsException
# Conflicts: # driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/unified/UnifiedServerDiscoveryAndMonitoringTest.java # driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedTest.java
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.
The only concern I left here was addressed.
Kicked off a full build just to check. https://spruce.mongodb.com/version/6698dcbb688ab00007faac91/ |
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.
Lets replace all the @since CSOT
doc annotations before merging into master.
The |
driver-core/src/main/com/mongodb/internal/operation/SyncOperations.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/internal/operation/SyncOperations.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/internal/operation/SyncOperations.java
Outdated
Show resolved
Hide resolved
...tive-streams/src/main/com/mongodb/reactivestreams/client/internal/OperationExecutorImpl.java
Outdated
Show resolved
Hide resolved
…ions.java Co-authored-by: Ross Lawley <[email protected]>
…ions.java Co-authored-by: Ross Lawley <[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
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.
Approved. LGTM!
Description
This PR introduces a unified Client Side Operation Timeout (CSOT) as an Alpha feature to
simplify the multitude of existing timeout settings. This consolidation merges various complex and interacting timeout settings into a single, overarching operation timeout option, enhancing usability and predictability. Existing timeout options will continue to be honored if the operation timeout is not set.
Key Changes:
Implement CSOT across various layers of the driver, applying the new operation
timeout configuration to govern execution time in areas such as Authentication,
Connection Pool and Monitoring, Server Discovery and Monitoring, CRUD, GridFS,
CSFLE, Transactions, Handshake, and Server Selection.
Annotate the CSOT API as Alpha, indicating that this public API element is in
the early stages of development and may undergo incompatible changes.
Centralize the setting of maxTimeMS just before sending commands to the server.
This optimization enhances performance and ensures more precise enforcement of timeouts.
Introduce TimeoutContext to centralize timeout-related logic, enhancing the
clarity and ease of maintenance for timeout management within the driver.
Enable a new retry mode when CSOT is active, allowing operations to retry until the timeout is reached. This improves resiliency compared to the previous behavior of retrying only once.
Enhance MongoClient, MongoDatabase, MongoCollection, and ClientSession to support
setting and inheriting the operation timeout.
Introduce MongoCluster, a new conceptual entity representing server deployments,
configurable with specific writeConcern, timeouts, and read preferences.
Transform timeout errors from external sources into the new MongoOperationTimeoutException,
standardizing error handling when CSOT is enabled.
Note:
serverSelectionTimeoutMS
andconnectTimeoutMS
are still honored even if CSOT is enabled.Reviewers:
@rozza: Since you have made many of the changes in this branch, I have added you as a reviewer. I have addressed and answered some comments on this PR but would appreciate if you could double-check and comment if you have any objections. A full review of the PR is not expected.
@stIncMale: Could you please check if your previous comments have been addressed and resolve them as needed? A full review of the PR is not expected.
For reviewers:
ClientSideOperation*
test suites does not have any ignored tests without a valid reason.Context:
This PR focuses on the alpha changes of CSOT and includes changes from the EPIC: JAVA-3828.
Description is updated by @vbabanin.