-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Ignore maxWaitTime when CSOT is enabled. #1744
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
base: main
Are you sure you want to change the base?
Conversation
driver-core/src/main/com/mongodb/internal/connection/DefaultConnectionPool.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/internal/connection/DefaultConnectionPool.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/internal/connection/DefaultConnectionPool.java
Outdated
Show resolved
Hide resolved
driver-core/src/test/functional/com/mongodb/internal/connection/DefaultConnectionPoolTest.java
Outdated
Show resolved
Hide resolved
...ync/src/test/functional/com/mongodb/client/AbstractClientSideOperationsTimeoutProseTest.java
Show resolved
Hide resolved
driver-core/src/test/functional/com/mongodb/internal/connection/DefaultConnectionPoolTest.java
Outdated
Show resolved
Hide resolved
...ync/src/test/functional/com/mongodb/client/AbstractClientSideOperationsTimeoutProseTest.java
Show resolved
Hide resolved
...ync/src/test/functional/com/mongodb/client/AbstractClientSideOperationsTimeoutProseTest.java
Outdated
Show resolved
Hide resolved
...ync/src/test/functional/com/mongodb/client/AbstractClientSideOperationsTimeoutProseTest.java
Outdated
Show resolved
Hide resolved
Add JavaDoc to StartTime. Shutdown executor properly.
...ync/src/test/functional/com/mongodb/client/AbstractClientSideOperationsTimeoutProseTest.java
Outdated
Show resolved
Hide resolved
The last reviewed commit is 820b131. |
…entSideOperationsTimeoutProseTest.java Co-authored-by: Valentin Kovalenko <[email protected]>
# Conflicts: # driver-core/src/main/com/mongodb/internal/connection/DefaultConnectionPool.java DRIVERS-2985: Allow on-demand client metadata updates after MongoClient initialization. (#1798)
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.
Pull Request Overview
This PR implements the functionality to ignore maxWaitTime
connection pool setting when Client-Side Operation Timeout (CSOT) is enabled, meaning when timeoutMS
is set. When CSOT is active, the operation timeout takes precedence over the connection pool's maximum wait time.
Key changes:
- Modified connection pool logic to use operation timeout instead of maxWaitTime when CSOT is enabled
- Added comprehensive test coverage for the new behavior
- Updated timeout context methods and error handling to support the new timeout precedence
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
AbstractClientSideOperationsTimeoutProseTest.java | Added three new test cases to verify maxWaitTime is ignored when timeoutMS is set |
ClientSideOperationTimeoutProseTest.java | Updated tearDown method signature to handle InterruptedException |
DefaultConnectionPoolTest.java | Added test for maxWaitTime behavior and refactored Thread.sleep usage |
DefaultConnectionPool.java | Core logic change to use operation timeout over maxWaitTime when CSOT is enabled |
TimeoutContext.java | Modified startMaxWaitTimeout method to return operation timeout when CSOT is active |
MongoOperationTimeoutException.java | Added @nullable annotation to constructor parameter |
LogMessage.java | Renamed log field from WAIT_QUEUE_TIMEOUT_MS to MAX_WAIT_TIMEOUT_MS |
Timeout.java | Added immutability documentation and import ordering fix |
StartTime.java | Added immutability documentation |
TimeoutTrackingConnectionGetter connectionGetter = new TimeoutTrackingConnectionGetter(provider, timeoutSettings); | ||
cachedExecutor.submit(connectionGetter); | ||
|
||
sleep(70); // wait for more than maxWaitTimeMS but less than timeoutMs. |
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.
Using a hard-coded sleep duration makes the test fragile and dependent on timing. Consider using a more deterministic approach or at least extract this value to a constant with a descriptive name.
sleep(70); // wait for more than maxWaitTimeMS but less than timeoutMs. | |
sleep(SLEEP_BEFORE_CLOSE_MS); // wait for more than maxWaitTimeMS but less than timeoutMs. |
Copilot uses AI. Check for mistakes.
} | ||
|
||
return timeoutContext.hasTimeoutMS() ? createMongoTimeoutException(errorMessage, cause) : new MongoTimeoutException(errorMessage, cause); | ||
} | ||
|
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.
[nitpick] This ternary operation creates different exception types based on the timeout context. Consider extracting this logic into a separate method to improve readability and make the intention clearer.
return createTimeoutExceptionBasedOnContext(errorMessage, cause, timeoutContext); | |
} | |
/** | |
* Creates a MongoTimeoutException based on the timeout context. | |
*/ | |
private MongoTimeoutException createTimeoutExceptionBasedOnContext(String errorMessage, @Nullable MongoTimeoutException cause, TimeoutContext timeoutContext) { | |
if (timeoutContext.hasTimeoutMS()) { | |
return createMongoTimeoutException(errorMessage, cause); | |
} else { | |
return new MongoTimeoutException(errorMessage, cause); | |
} | |
} |
Copilot uses AI. Check for mistakes.
JAVA-5409