This is an automated email from the ASF dual-hosted git repository.
ptupitsyn pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git
The following commit(s) were added to refs/heads/main by this push:
new d2a9706329 IGNITE-19069 .NET: Fix TestReconnectAfterFullClusterRestart
flakiness (#1828)
d2a9706329 is described below
commit d2a970632927177ffbea49c22d09433c44ef235a
Author: Pavel Tupitsyn <[email protected]>
AuthorDate: Thu Mar 23 08:33:52 2023 +0300
IGNITE-19069 .NET: Fix TestReconnectAfterFullClusterRestart flakiness
(#1828)
* Use double check locking in `ClientFailoverSocket.ConnectAsync` to avoid
connecting the same endpoint twice (this was the root cause of flakiness:
`FakeServer` does not support multiple connections. But this is also a bug -
two connections to the same server should not happen).
* Handle `ObjectDisposedException` when sending requests (may happen
connection is closed concurrently).
* Increase `SocketTimeout` - 200ms is too short.
---
modules/platforms/dotnet/Apache.Ignite.Tests/ReconnectTests.cs | 2 +-
.../platforms/dotnet/Apache.Ignite/Internal/ClientFailoverSocket.cs | 5 +++++
modules/platforms/dotnet/Apache.Ignite/Internal/ClientSocket.cs | 2 +-
modules/platforms/dotnet/Apache.Ignite/Internal/SocketEndpoint.cs | 5 +++++
4 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/modules/platforms/dotnet/Apache.Ignite.Tests/ReconnectTests.cs
b/modules/platforms/dotnet/Apache.Ignite.Tests/ReconnectTests.cs
index 57fffde958..e5212a4b08 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Tests/ReconnectTests.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Tests/ReconnectTests.cs
@@ -135,7 +135,7 @@ public class ReconnectTests
var cfg = new IgniteClientConfiguration
{
ReconnectInterval = TimeSpan.FromMilliseconds(100),
- SocketTimeout = TimeSpan.FromMilliseconds(200),
+ SocketTimeout = TimeSpan.FromSeconds(2),
Logger = logger
};
diff --git
a/modules/platforms/dotnet/Apache.Ignite/Internal/ClientFailoverSocket.cs
b/modules/platforms/dotnet/Apache.Ignite/Internal/ClientFailoverSocket.cs
index d8a8c9570c..2472c4a916 100644
--- a/modules/platforms/dotnet/Apache.Ignite/Internal/ClientFailoverSocket.cs
+++ b/modules/platforms/dotnet/Apache.Ignite/Internal/ClientFailoverSocket.cs
@@ -409,6 +409,11 @@ namespace Apache.Ignite.Internal
await _socketLock.WaitAsync().ConfigureAwait(false);
+ if (endpoint.Socket?.IsDisposed == false)
+ {
+ return endpoint.Socket;
+ }
+
try
{
var socket = await ClientSocket.ConnectAsync(endpoint,
Configuration, OnAssignmentChanged).ConfigureAwait(false);
diff --git a/modules/platforms/dotnet/Apache.Ignite/Internal/ClientSocket.cs
b/modules/platforms/dotnet/Apache.Ignite/Internal/ClientSocket.cs
index f9630ee4e0..da9aef297a 100644
--- a/modules/platforms/dotnet/Apache.Ignite/Internal/ClientSocket.cs
+++ b/modules/platforms/dotnet/Apache.Ignite/Internal/ClientSocket.cs
@@ -256,7 +256,7 @@ namespace Apache.Ignite.Internal
{
var completionSource =
(TaskCompletionSource<PooledBuffer>)state!;
- if (task.IsCanceled ||
task.Exception?.GetBaseException() is TaskCanceledException)
+ if (task.IsCanceled ||
task.Exception?.GetBaseException() is TaskCanceledException or
ObjectDisposedException)
{
// Canceled task means Dispose was called.
completionSource.TrySetException(
diff --git a/modules/platforms/dotnet/Apache.Ignite/Internal/SocketEndpoint.cs
b/modules/platforms/dotnet/Apache.Ignite/Internal/SocketEndpoint.cs
index fd79835b3a..762fa3c890 100644
--- a/modules/platforms/dotnet/Apache.Ignite/Internal/SocketEndpoint.cs
+++ b/modules/platforms/dotnet/Apache.Ignite/Internal/SocketEndpoint.cs
@@ -48,7 +48,12 @@ namespace Apache.Ignite.Internal
set
{
Debug.Assert(value != null, "value != null");
+
+ var oldValue = _socket;
+
_socket = value;
+
+ oldValue?.Dispose();
}
}