Uploaded image for project: 'Ignite'
  1. Ignite
  2. IGNITE-8978

Affinity throws "IgniteException: Failed to find cache" after an Ignite client re-connect

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.5
    • None
    • None
    • None
    • ver. 2.5.0#20180523-sha1:86e110c7
      OS: Windows 7 6.1 amd64
      Java(TM) SE Runtime Environment 1.8.0_101-b13 Oracle Corporation Java HotSpot(TM) 64-Bit Server VM 25.101-b13

    Description

      Use case:

      1. A single Ignite server node is deployed and running.
      2. An ignite Java client connects to the server node and starts to do cache operations (put/get) + invoke Affinity.mapKeyToNode() method.
      3. The Ignite server process is killed
      4. Waiting for some time
      5. Starting the Ignite server back.
      public static void main(String ... args) throws InterruptedException {
          Ignition.setClientMode(true);
          String config = "ignite-config.xml";
          try (Ignite ignite = Ignition.start(config)) {
              String cacheName = "testCache";
              IgniteCache<String, String> cache = ignite.cache(cacheName);
              Affinity<String> affinity = ignite.affinity(cacheName);
      
              while (true) {
                  try {
                      String key = "testKey";
                      cache.put(key, "testValue");
                      String value = cache.get(key);
                      ClusterNode primary = affinity.mapKeyToNode(key);
                      System.out.println("read value: " + value + ", primary node: " + primary);
                  } catch (Exception e) {
                      System.out.println("Error: " + e.toString());
                      e.printStackTrace();
                  } finally {
                      Thread.sleep(1000);
                  }
              }
          }
      }
      

      Expected result:
      affinity.mapKeyToNode(key) starts to work after a re-connection to the restarted server

      Actual result:
      affinity.mapKeyToNode(key) continues to throw the following exception:

      class org.apache.ignite.IgniteException: Failed to find cache (cache was not started yet or cache was already stopped): testCache
      	at org.apache.ignite.internal.processors.cache.GridCacheAffinityManager.affinityTopologyVersion(GridCacheAffinityManager.java:402)
      	at org.apache.ignite.internal.processors.cache.affinity.GridCacheAffinityImpl.topologyVersion(GridCacheAffinityImpl.java:241)
      	at org.apache.ignite.internal.processors.cache.affinity.GridCacheAffinityImpl.mapKeysToNodes(GridCacheAffinityImpl.java:189)
      	at org.apache.ignite.internal.processors.cache.affinity.GridCacheAffinityImpl.mapKeyToNode(GridCacheAffinityImpl.java:182)
      	at test.ignite.Main.main(Main.java:25)
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              dnk Dmitry Konstantinov
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated: