-
Notifications
You must be signed in to change notification settings - Fork 1.5k
CSOT: Ignore wTimeoutMS #1368
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: Ignore wTimeoutMS #1368
Changes from all commits
02936e5
e075faf
3b42448
2182882
795d2ff
9e46d55
e82b933
1ae61de
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 |
---|---|---|
|
@@ -203,7 +203,7 @@ private void doAdvanceOrThrow(final Throwable attemptException, | |
*/ | ||
if (hasTimeoutMs() && !loopState.isLastIteration()) { | ||
previouslyChosenException = createMongoTimeoutException( | ||
"MongoDB operation timed out during a retry attempt", | ||
"Retry attempt timed out.", | ||
previouslyChosenException); | ||
} | ||
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 retry could be triggered not only by transient errors in MongoDB operations but also within the scope of OIDC. Referring to it as a ' |
||
throw previouslyChosenException; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ | |
import com.mongodb.MongoClientException; | ||
import com.mongodb.ServerAddress; | ||
import com.mongodb.TransactionOptions; | ||
import com.mongodb.WriteConcern; | ||
import com.mongodb.internal.TimeoutContext; | ||
import com.mongodb.internal.TimeoutSettings; | ||
import com.mongodb.internal.binding.ReferenceCounted; | ||
|
@@ -29,6 +30,7 @@ | |
import org.bson.BsonDocument; | ||
import org.bson.BsonTimestamp; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
import java.util.concurrent.atomic.AtomicBoolean; | ||
|
||
import static com.mongodb.assertions.Assertions.assertTrue; | ||
|
@@ -55,6 +57,14 @@ public class BaseClientSessionImpl implements ClientSession { | |
@Nullable | ||
private TimeoutContext timeoutContext; | ||
|
||
protected static boolean hasTimeoutMS(@Nullable final TimeoutContext timeoutContext) { | ||
return timeoutContext != null && timeoutContext.hasTimeoutMS(); | ||
} | ||
|
||
protected static boolean hasWTimeoutMS(@Nullable final WriteConcern writeConcern) { | ||
return writeConcern != null && writeConcern.getWTimeout(TimeUnit.MILLISECONDS) != null; | ||
} | ||
|
||
public BaseClientSessionImpl(final ServerSessionPool serverSessionPool, final Object originator, final ClientSessionOptions options) { | ||
this.serverSessionPool = serverSessionPool; | ||
this.originator = originator; | ||
|
@@ -228,4 +238,8 @@ protected TimeoutSettings getTimeoutSettings(final TransactionOptions transactio | |
.withMaxCommitMS(transactionOptions.getMaxCommitTime(MILLISECONDS)) | ||
.withTimeout(timeoutMS, MILLISECONDS); | ||
} | ||
|
||
protected enum TransactionState { | ||
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. 👍 |
||
NONE, IN, COMMITTED, ABORTED | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright 2008-present MongoDB, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.mongodb.internal.operation; | ||
|
||
import com.mongodb.WriteConcern; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.MethodSource; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
|
||
import static com.mongodb.assertions.Assertions.assertNull; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
class WriteConcernHelperTest { | ||
|
||
static WriteConcern[] shouldRemoveWtimeout(){ | ||
return new WriteConcern[]{ | ||
WriteConcern.ACKNOWLEDGED, | ||
WriteConcern.MAJORITY, | ||
WriteConcern.W1, | ||
WriteConcern.W2, | ||
WriteConcern.W3, | ||
WriteConcern.UNACKNOWLEDGED, | ||
WriteConcern.JOURNALED, | ||
|
||
WriteConcern.ACKNOWLEDGED.withWTimeout(100, TimeUnit.MILLISECONDS), | ||
WriteConcern.MAJORITY.withWTimeout(100, TimeUnit.MILLISECONDS), | ||
WriteConcern.W1.withWTimeout(100, TimeUnit.MILLISECONDS), | ||
WriteConcern.W2.withWTimeout(100, TimeUnit.MILLISECONDS), | ||
WriteConcern.W3.withWTimeout(100, TimeUnit.MILLISECONDS), | ||
WriteConcern.UNACKNOWLEDGED.withWTimeout(100, TimeUnit.MILLISECONDS), | ||
WriteConcern.JOURNALED.withWTimeout(100, TimeUnit.MILLISECONDS), | ||
}; | ||
} | ||
|
||
@MethodSource | ||
@ParameterizedTest | ||
void shouldRemoveWtimeout(final WriteConcern writeConcern){ | ||
//when | ||
WriteConcern clonedWithoutTimeout = WriteConcernHelper.cloneWithoutTimeout(writeConcern); | ||
|
||
//then | ||
assertEquals(writeConcern.getWObject(), clonedWithoutTimeout.getWObject()); | ||
assertEquals(writeConcern.getJournal(), clonedWithoutTimeout.getJournal()); | ||
assertNull(clonedWithoutTimeout.getWTimeout(TimeUnit.MILLISECONDS)); | ||
} | ||
} |
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.
This statement appears to be a duplicate of the one found on line 36.