Search code examples
cachingignite

apache ignite destroycache socket-timeout or very slow


download the example here:https://github.com/apache/ignite/tree/master/modules/platforms/dotnet/examples

Adjust the code in ServerNode.Program.cs

   namespace Apache.Ignite.Examples.ServerNode
{
    public static class Program
    {
        public static void Main()
        {
            using (var ignite = Ignition.Start(Utils.GetServerNodeConfiguration()))
            {
                ignite.GetCluster().SetActive(true);  **//add one line code here**
                Utils.DeployDefaultServices(ignite);
                .....
            }
        }
    }
}

Adjust the code in Util.cs

public static IgniteConfiguration GetServerNodeConfiguration()
        {
            return new IgniteConfiguration
            {
                Localhost = "127.0.0.1",
                .......
                PeerAssemblyLoadingMode = PeerAssemblyLoadingMode.CurrentAppDomain,
                **//add some code here to enable persistence**
                DataStorageConfiguration = new DataStorageConfiguration
                {
                    DefaultDataRegionConfiguration = new DataRegionConfiguration
                    {
                        Name = "Default_Region",
                        PersistenceEnabled = true 
                    }
                }
            };
        }

Add the destroycache method into Apache.Ignite.Examples.Thin.Sql.LinqThin.Program Main method like this:

public static void Main()
        {
            using (var ignite = Ignition.StartClient(Utils.GetThinClientConfiguration()))
            {
                Console.WriteLine();
                Console.WriteLine(">>> Cache LINQ example started.");
                ........

                var sw = Stopwatch.StartNew();
                ignite.DestroyCache(OrganizationCacheName);
                sw.Stop();
                Console.WriteLine($"DESTROY COST {sw.ElapsedMilliseconds}");
                .....
            }

             ....
        }

When execute the detroyCache method, it throws socket timeout exception sometimes, or it cost long time sometimes if destroy successfully. But all is OK when destroyCache if donot enable persistence.


Solution

  • Creating and destroying caches can be slower with persistence, especially on HDD (as opposed to SSD).

    You can increase socket timeout like this:

                var cfg = new IgniteClientConfiguration
                {
                    ...
                    SocketTimeout = TimeSpan.FromSeconds(15)
                };
    

    That being said, I've tried the steps above and it prints DESTROY COST 140 on my machine (Core i7-9700, SSD).