Skip to content
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

Draft
wants to merge 166 commits into
base: master
Choose a base branch
from
Draft

CSOT #1215

wants to merge 166 commits into from

Conversation

katcharov
Copy link
Contributor

rozza and others added 28 commits August 22, 2023 14:43
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
Copy link
Contributor Author

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)

* @since CSOT
* @see #getTimeout
*/
MongoCollection<TDocument> withTimeout(long timeout, TimeUnit timeUnit);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

See #1349 (comment) - clarify regarding use of times below 1ms.

Comment on lines 243 to 246
public void resetTimeout() {
assertNotNull(timeout);
timeout = calculateTimeout(timeoutSettings.getTimeoutMS());
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Consider changing to resetTimeoutIfPresent, with an if check on null rather than the assert. All prod usages perform this check before calling.

rozza and others added 21 commits April 3, 2024 13:40
Also prevent NPE leak from TlsChannelImpl
Also added temp fix for timeoutRemainingMS (scheduled to be removed)

JAVA-5401

Added temp fix for timeoutRemainingMS which will eventually be removed
Added createOptions support for collection creation
Fixed error with awaitable tailable cursors
Manually change tests to use defaultTimeoutMS for the session as there is no operation overrdie
Disable test JAVA-5406 - ClientSideEncryptionTest timeoutMS.json

JAVA-5374
Add CSOT error transformation.

JAVA-5248

Co-authored-by: Ross Lawley <ross@mongodb.com>
- Resolve regression where CSOT exception is exposed despite CSOT being disabled.
- Correct premature decrease in connect timeout before connection initiation.
- Encapsulate logic within TimeoutContext.

JAVA-5439
JAVA-5402

Co-authored-by: Valentin Kovalenko <valentin.male.kovalenko@gmail.com>
Co-authored-by: Valentin Kovalenko <valentin.kovalenko@mongodb.com>
Co-authored-by: Maxim Katcharov <maxim.katcharov@mongodb.com>
Co-authored-by: Jeff Yemin <jeff.yemin@mongodb.com>
Co-authored-by: ashni <105304831+ashni-mongodb@users.noreply.github.com>
# Conflicts:
#	THIRD-PARTY-NOTICES
#	config/spotbugs/exclude.xml
#	driver-core/src/main/com/mongodb/internal/connection/Authenticator.java
#	driver-core/src/main/com/mongodb/internal/connection/DefaultAuthenticator.java
#	driver-core/src/main/com/mongodb/internal/connection/InternalConnection.java
#	driver-core/src/main/com/mongodb/internal/connection/InternalStreamConnection.java
#	driver-core/src/main/com/mongodb/internal/connection/InternalStreamConnectionInitializer.java
#	driver-core/src/main/com/mongodb/internal/connection/OidcAuthenticator.java
#	driver-core/src/main/com/mongodb/internal/connection/SaslAuthenticator.java
#	driver-core/src/test/functional/com/mongodb/ClusterFixture.java
#	driver-core/src/test/unit/com/mongodb/internal/connection/AbstractConnectionPoolTest.java
#	driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/syncadapter/SyncMongoClient.java
#	driver-sync/src/test/functional/com/mongodb/client/csot/ClientSideOperationsEncryptionTimeoutProseTest.java
#	driver-sync/src/test/functional/com/mongodb/client/unified/Entities.java
Copy link

There is an existing patch(es) for this commit SHA:

Please note that the status that is posted is not in the context of this PR but rather the (latest) existing patch and that may affect some tests that may depend on the particular PR. If your tests do not rely on any PR-specific values (like base or head branch name) then your tests will report the same status. If you would like a patch to run in the context of this PR and abort the other(s), comment 'evergreen retry'.

# Conflicts:
#	driver-sync/src/main/com/mongodb/client/gridfs/GridFSDownloadStreamImpl.java
#	driver-sync/src/main/com/mongodb/client/gridfs/GridFSUploadStreamImpl.java
- Mark session as dirty when MongoSocketException occurs.
- Skip killCursors command execution when getMore fails in LOAD_BALANCER mode.

JAVA-5474
JAVA-5476
- Re-enable tests that were previously disabled.
- Add additional assertions to enhance test reliability.
- Implement ignoreExtraEvents override to address flakiness in tests with race conditions.
- Fix issue where timeoutContext is null in subsequent commit transactions.
- Reduce timeouts in serverless tests to ensure they pass.

JAVA-5104
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants