-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Client Backpressure #1918
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?
Client Backpressure #1918
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -172,7 +172,8 @@ private InternalConnectionInitializationDescription createInitializationDescript | |
|
|
||
| private BsonDocument createHelloCommand(final Authenticator authenticator, final InternalConnection connection) { | ||
| BsonDocument helloCommandDocument = new BsonDocument(getHandshakeCommandName(), new BsonInt32(1)) | ||
| .append("helloOk", BsonBoolean.TRUE); | ||
| .append("helloOk", BsonBoolean.TRUE) | ||
| .append("backpressure", BsonBoolean.TRUE); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The commit ac1c120 introduced by #1906 for JAVA-6035 should have implemented, as far as I understand, the If the above is correct, let's reopen JAVA-6035 and create another PR for that ticket that will implement the prose test.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for catching this. I reopened https://jira.mongodb.org/browse/JAVA-6035 |
||
| if (clientMetadataDocument != null) { | ||
| helloCommandDocument.append("client", clientMetadataDocument); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,7 +37,9 @@ | |
| import static org.junit.jupiter.api.Assertions.fail; | ||
| import static org.junit.jupiter.api.Assumptions.assumeTrue; | ||
|
|
||
| // See https://github.com/mongodb/specifications/blob/master/source/transactions-convenient-api/tests/README.md#prose-tests | ||
| /** | ||
| * <a href="https://github.com/mongodb/specifications/blob/master/source/transactions-convenient-api/tests/README.md#prose-tests">Prose Tests</a>. | ||
| */ | ||
| public class WithTransactionProseTest extends DatabaseTestCase { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| private static final long START_TIME_MS = 1L; | ||
| private static final long ERROR_GENERATING_INTERVAL = 121000L; | ||
|
|
@@ -52,11 +54,10 @@ public void setUp() { | |
| collection.insertOne(Document.parse("{ _id : 0 }")); | ||
| } | ||
|
|
||
| // | ||
| // Test that the callback raises a custom exception or error that does not include either UnknownTransactionCommitResult or | ||
| // TransientTransactionError error labels. The callback will execute using withTransaction and assert that the callback's error | ||
| // bypasses any retry logic within withTransaction and is propagated to the caller of withTransaction. | ||
| // | ||
| /** | ||
| * <a href="https://github.com/mongodb/specifications/blob/master/source/transactions-convenient-api/tests/README.md#callback-raises-a-custom-error"> | ||
| * Callback Raises a Custom Error</a>. | ||
| */ | ||
| @Test | ||
| public void testCallbackRaisesCustomError() { | ||
| final String exceptionMessage = "NotTransientOrUnknownError"; | ||
|
|
@@ -71,10 +72,10 @@ public void testCallbackRaisesCustomError() { | |
| } | ||
| } | ||
|
|
||
| // | ||
| // Test that the callback that returns a custom value (e.g. boolean, string, object). Execute this callback using withTransaction | ||
| // and assert that the callback's return value is propagated to the caller of withTransaction. | ||
| // | ||
| /** | ||
| * <a href="https://github.com/mongodb/specifications/blob/master/source/transactions-convenient-api/tests/README.md#callback-returns-a-value"> | ||
| * Callback Returns a Value</a>. | ||
| */ | ||
| @Test | ||
| public void testCallbackReturnsValue() { | ||
| try (ClientSession session = client.startSession()) { | ||
|
|
@@ -87,10 +88,10 @@ public void testCallbackReturnsValue() { | |
| } | ||
| } | ||
|
|
||
| // | ||
| // If the callback raises an error with the TransientTransactionError label and the retry timeout has been exceeded, withTransaction | ||
| // should propagate the error to its caller. | ||
| // | ||
| /** | ||
| * <a href="https://github.com/mongodb/specifications/blob/master/source/transactions-convenient-api/tests/README.md#retry-timeout-is-enforced"> | ||
| * Retry Timeout is Enforced</a>, first scenario on the list. | ||
| */ | ||
| @Test | ||
| public void testRetryTimeoutEnforcedTransientTransactionError() { | ||
| final String errorMessage = "transient transaction error"; | ||
|
|
@@ -110,10 +111,10 @@ public void testRetryTimeoutEnforcedTransientTransactionError() { | |
| } | ||
| } | ||
|
|
||
| // | ||
| // If committing raises an error with the UnknownTransactionCommitResult label, the error is not a write concern timeout, and the | ||
| // retry timeout has been exceeded, withTransaction should propagate the error to its caller. | ||
| // | ||
| /** | ||
| * <a href="https://github.com/mongodb/specifications/blob/master/source/transactions-convenient-api/tests/README.md#retry-timeout-is-enforced"> | ||
| * Retry Timeout is Enforced</a>, second scenario on the list. | ||
| */ | ||
| @Test | ||
| public void testRetryTimeoutEnforcedUnknownTransactionCommit() { | ||
| MongoDatabase failPointAdminDb = client.getDatabase("admin"); | ||
|
|
@@ -137,11 +138,10 @@ public void testRetryTimeoutEnforcedUnknownTransactionCommit() { | |
| } | ||
| } | ||
|
|
||
| // | ||
| // If committing raises an error with the TransientTransactionError label and the retry timeout has been exceeded, withTransaction | ||
| // should propagate the error to its caller. This case may occur if the commit was internally retried against a new primary after | ||
| // a failover and the second primary returned a NoSuchTransaction error response. | ||
| // | ||
| /** | ||
| * <a href="https://github.com/mongodb/specifications/blob/master/source/transactions-convenient-api/tests/README.md#retry-timeout-is-enforced"> | ||
| * Retry Timeout is Enforced</a>, third scenario on the list. | ||
| */ | ||
| @Test | ||
| public void testRetryTimeoutEnforcedTransientTransactionErrorOnCommit() { | ||
| MongoDatabase failPointAdminDb = client.getDatabase("admin"); | ||
|
|
@@ -166,9 +166,9 @@ public void testRetryTimeoutEnforcedTransientTransactionErrorOnCommit() { | |
| } | ||
| } | ||
|
|
||
| // | ||
| // Ensure cannot override timeout in transaction | ||
| // | ||
| /** | ||
| * Ensure cannot override timeout in transaction. | ||
| */ | ||
| @Test | ||
| public void testTimeoutMS() { | ||
| try (ClientSession session = client.startSession(ClientSessionOptions.builder() | ||
|
|
@@ -182,9 +182,9 @@ public void testTimeoutMS() { | |
| } | ||
| } | ||
|
|
||
| // | ||
| // Ensure legacy settings don't cause issues in sessions | ||
| // | ||
| /** | ||
| * Ensure legacy settings don't cause issues in sessions. | ||
| */ | ||
| @Test | ||
| public void testTimeoutMSAndLegacySettings() { | ||
| try (ClientSession session = client.startSession(ClientSessionOptions.builder() | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
TODO-BACKPRESSURE ValentinBefore merging in
main, make sure that all the code in thebackpressurebranch uses theMongoException.TRANSIENT_TRANSACTION_ERROR_LABEL/UNKNOWN_TRANSACTION_COMMIT_RESULT_LABEL/SYSTEM_OVERLOADED_ERROR_LABEL/RETRYABLE_ERROR_LABELandCommandOperationHelper.RETRYABLE_WRITE_ERROR_LABEL/NO_WRITES_PERFORMED_ERROR_LABELconstants instead of using theTransientTransactionError/UnknownTransactionCommitResult/SystemOverloadedError/RetryableErrorandRetryableWriteError/NoWritesPerformedliterals.