From 10aa761ad00038188495843f1daa20e37d42f20c Mon Sep 17 00:00:00 2001 From: Oleksandr Poliakov Date: Thu, 2 Oct 2025 12:11:42 -0700 Subject: [PATCH] CSHARP-5744: Fix interruptInUse flaky tests --- .../Core/Connections/BinaryConnection.cs | 17 ----------------- .../Specifications/UnifiedTestSpecRunner.cs | 6 ------ 2 files changed, 23 deletions(-) diff --git a/src/MongoDB.Driver/Core/Connections/BinaryConnection.cs b/src/MongoDB.Driver/Core/Connections/BinaryConnection.cs index 565cb3f9798..a775f7dff0d 100644 --- a/src/MongoDB.Driver/Core/Connections/BinaryConnection.cs +++ b/src/MongoDB.Driver/Core/Connections/BinaryConnection.cs @@ -421,7 +421,6 @@ public ResponseMessage ReceiveMessage( catch (Exception ex) { helper.FailedReceivingMessage(ex); - ThrowOperationCanceledExceptionIfRequired(ex); throw; } } @@ -457,7 +456,6 @@ public async Task ReceiveMessageAsync( catch (Exception ex) { helper.FailedReceivingMessage(ex); - ThrowOperationCanceledExceptionIfRequired(ex); throw; } } @@ -540,7 +538,6 @@ public void SendMessage(OperationContext operationContext, RequestMessage messag catch (Exception ex) { helper.FailedSendingMessage(ex); - ThrowOperationCanceledExceptionIfRequired(ex); throw; } } @@ -577,7 +574,6 @@ public async Task SendMessageAsync(OperationContext operationContext, RequestMes catch (Exception ex) { helper.FailedSendingMessage(ex); - ThrowOperationCanceledExceptionIfRequired(ex); throw; } } @@ -687,19 +683,6 @@ ex is OperationCanceledException || return new MongoConnectionException(_connectionId, message, ex); } - private void ThrowOperationCanceledExceptionIfRequired(Exception exception) - { - if (exception is ObjectDisposedException objectDisposedException) - { - // We expect two cases here: - // objectDisposedException.ObjectName == GetType().Name - // objectDisposedException.Message == "The semaphore has been disposed." - // but since the last one is language-specific, the only option we have is avoiding any additional conditions for ObjectDisposedException - // TODO: this logic should be reviewed in the scope of https://jira.mongodb.org/browse/CSHARP-3165 - throw new OperationCanceledException($"The {nameof(BinaryConnection)} operation has been cancelled.", exception); - } - } - // nested classes private class OpenConnectionHelper { diff --git a/tests/MongoDB.Driver.Tests/Specifications/UnifiedTestSpecRunner.cs b/tests/MongoDB.Driver.Tests/Specifications/UnifiedTestSpecRunner.cs index c5560922882..7ade86c99c3 100644 --- a/tests/MongoDB.Driver.Tests/Specifications/UnifiedTestSpecRunner.cs +++ b/tests/MongoDB.Driver.Tests/Specifications/UnifiedTestSpecRunner.cs @@ -279,12 +279,6 @@ private static void RequireKmsMock() => "collection.listIndexNames succeeds after retryable handshake network error", // SDAM -#if NET472 - // https://jira.mongodb.org/browse/CSHARP-3165 - "Connection pool clear uses interruptInUseConnections=true after monitor timeout", - "Error returned from connection pool clear with interruptInUseConnections=true is retryable", - "Error returned from connection pool clear with interruptInUseConnections=true is retryable for write", -#endif // "Not implemented: https://jira.mongodb.org/browse/CSHARP-3138" "connectTimeoutMS=0", // https://jira.mongodb.org/browse/CSHARP-4459