Skip to content

Commit 082f1d7

Browse files
CSHARP-2905: Make ExceededTimeLimit retryable writes error.
1 parent 11b39ef commit 082f1d7

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/MongoDB.Driver.Core/ServerErrorCode.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace MongoDB.Driver
1818
internal enum ServerErrorCode
1919
{
2020
// this is not a complete list, more will be added as needed
21-
// see: https://github.com/mongodb/mongo/blob/master/src/mongo/base/error_codes.err
21+
// see: https://github.com/mongodb/mongo/blob/master/src/mongo/base/error_codes.yml
2222
CappedPositionLost = 136,
2323
CursorKilled = 237,
2424
ElectionInProgress = 216,

src/MongoDB.Driver/TransactionExecutor.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ internal static class TransactionExecutor
2626
// constants
2727
private const string TransientTransactionErrorLabel = "TransientTransactionError";
2828
private const string UnknownTransactionCommitResultLabel = "UnknownTransactionCommitResult";
29-
private const int ExceededTimeLimitErrorCode = 50;
29+
private const int MaxTimeMSExpiredErrorCode = 50;
3030
private static readonly TimeSpan __transactionTimeout = TimeSpan.FromSeconds(120);
3131

3232
public static TResult ExecuteWithRetries<TResult>(
@@ -207,10 +207,10 @@ private static bool HasErrorLabel(Exception ex, string errorLabel)
207207
}
208208
}
209209

210-
private static bool IsExceededTimeLimitException(Exception ex)
210+
private static bool IsMaxTimeMSExpiredException(Exception ex)
211211
{
212212
if (ex is MongoExecutionTimeoutException timeoutException &&
213-
timeoutException.Code == ExceededTimeLimitErrorCode)
213+
timeoutException.Code == MaxTimeMSExpiredErrorCode)
214214
{
215215
return true;
216216
}
@@ -221,7 +221,7 @@ private static bool IsExceededTimeLimitException(Exception ex)
221221
if (writeConcernError != null)
222222
{
223223
var code = writeConcernError.GetValue("code", -1).ToInt32();
224-
if (code == ExceededTimeLimitErrorCode)
224+
if (code == MaxTimeMSExpiredErrorCode)
225225
{
226226
return true;
227227
}
@@ -250,7 +250,7 @@ private static bool ShouldRetryCommit(Exception ex, DateTime startTime, DateTime
250250
return
251251
HasErrorLabel(ex, UnknownTransactionCommitResultLabel) &&
252252
!HasTimedOut(startTime, now) &&
253-
!IsExceededTimeLimitException(ex);
253+
!IsMaxTimeMSExpiredException(ex);
254254
}
255255

256256
// nested types

0 commit comments

Comments
 (0)