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 3f8c96df73c IGNITE-28342 .NET: Fix redundant OPERATION_CANCEL requests 
(#7860)
3f8c96df73c is described below

commit 3f8c96df73c6c912ff0f3f7e81ad64a55323cc7c
Author: Pavel Tupitsyn <[email protected]>
AuthorDate: Thu Mar 26 11:19:07 2026 +0100

    IGNITE-28342 .NET: Fix redundant OPERATION_CANCEL requests (#7860)
---
 .../platforms/dotnet/Apache.Ignite/Internal/ClientSocket.cs   |  6 +++---
 .../dotnet/Apache.Ignite/Internal/Proto/ClientOpExtensions.cs | 11 +++++++++++
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/modules/platforms/dotnet/Apache.Ignite/Internal/ClientSocket.cs 
b/modules/platforms/dotnet/Apache.Ignite/Internal/ClientSocket.cs
index 8d41b343537..be050d1ae17 100644
--- a/modules/platforms/dotnet/Apache.Ignite/Internal/ClientSocket.cs
+++ b/modules/platforms/dotnet/Apache.Ignite/Internal/ClientSocket.cs
@@ -708,7 +708,7 @@ namespace Apache.Ignite.Internal
             {
                 await SendRequestAsync(request, clientOp, requestId, 
cancellationToken).ConfigureAwait(false);
 
-                await using var cancellation = RegisterCancellation(requestId, 
cancellationToken).ConfigureAwait(false);
+                await using var cancellation = RegisterCancellation(requestId, 
clientOp, cancellationToken).ConfigureAwait(false);
 
                 PooledBuffer resBuf = await 
taskCompletionSource.Task.ConfigureAwait(false);
                 resBuf.Metadata = notificationHandler;
@@ -739,8 +739,8 @@ namespace Apache.Ignite.Internal
             }
         }
 
-        private CancellationTokenRegistration RegisterCancellation(long 
requestId, CancellationToken cancellationToken) =>
-            cancellationToken == CancellationToken.None
+        private CancellationTokenRegistration RegisterCancellation(long 
requestId, ClientOp op, CancellationToken cancellationToken) =>
+            cancellationToken == CancellationToken.None || !op.IsCancellable()
                 ? default
                 : cancellationToken.Register(() => _ = 
CancelRequestAsync(requestId));
 
diff --git 
a/modules/platforms/dotnet/Apache.Ignite/Internal/Proto/ClientOpExtensions.cs 
b/modules/platforms/dotnet/Apache.Ignite/Internal/Proto/ClientOpExtensions.cs
index c5bb8b14ad5..a956b23820f 100644
--- 
a/modules/platforms/dotnet/Apache.Ignite/Internal/Proto/ClientOpExtensions.cs
+++ 
b/modules/platforms/dotnet/Apache.Ignite/Internal/Proto/ClientOpExtensions.cs
@@ -82,5 +82,16 @@ namespace Apache.Ignite.Internal.Proto
                 ClientOp.None or _ => throw new 
ArgumentOutOfRangeException(nameof(op), op, message: null)
             };
         }
+
+        /// <summary>
+        /// Returns true for operations that can be cancelled via <see 
cref="ClientOp.OperationCancel"/>.
+        /// </summary>
+        /// <param name="op">Op.</param>
+        /// <returns>Whether the op is cancellable with <see 
cref="ClientOp.OperationCancel"/>.</returns>
+        public static bool IsCancellable(this ClientOp op) => op switch
+        {
+            ClientOp.SqlExec or ClientOp.SqlExecScript or 
ClientOp.SqlExecBatch => true,
+            _ => false
+        };
     }
 }

Reply via email to