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 e6d10daa0f9 IGNITE-26393 .NET: Fix schema caching race condition 
(#6608)
e6d10daa0f9 is described below

commit e6d10daa0f9464c51076576397802ab900e401a6
Author: Pavel Tupitsyn <[email protected]>
AuthorDate: Mon Sep 22 13:41:27 2025 +0300

    IGNITE-26393 .NET: Fix schema caching race condition (#6608)
    
    Fix unintended retry when schema task fails quickly. This fixes 
`TestFailedSchemaLoadTaskIsRetried` flakiness.
---
 .../dotnet/Apache.Ignite/Internal/Table/Table.cs      | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/modules/platforms/dotnet/Apache.Ignite/Internal/Table/Table.cs 
b/modules/platforms/dotnet/Apache.Ignite/Internal/Table/Table.cs
index a0863aacbfb..e178decae41 100644
--- a/modules/platforms/dotnet/Apache.Ignite/Internal/Table/Table.cs
+++ b/modules/platforms/dotnet/Apache.Ignite/Internal/Table/Table.cs
@@ -267,19 +267,22 @@ namespace Apache.Ignite.Internal.Table
 
         private Task<Schema> GetCachedSchemaAsync(int version)
         {
-            var task = GetOrAdd();
-
-            if (!task.IsFaulted)
+            if (_schemas.TryGetValue(version, out var task))
             {
-                return task;
-            }
+                if (!task.IsFaulted)
+                {
+                    return task;
+                }
 
-            // Do not return failed task. Remove it from the cache and try 
again.
-            _schemas.TryRemove(new KeyValuePair<int, Task<Schema>>(version, 
task));
+                // Do not return old failed task. Remove it from the cache and 
try again.
+                _schemas.TryRemove(KeyValuePair.Create(version, task));
+            }
 
             return GetOrAdd();
 
-            Task<Schema> GetOrAdd() => _schemas.GetOrAdd(version, static (ver, 
tbl) => tbl.LoadSchemaAsync(ver), this);
+            // Note: GetOrAdd does not guarantee that the factory is called 
only once.
+            Task<Schema> GetOrAdd() =>
+                _schemas.GetOrAdd(version, static (ver, tbl) => 
tbl.LoadSchemaAsync(ver), this);
         }
 
         /// <summary>

Reply via email to