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

ignite.getOrCreateCache(cacheConfig).iterator() method works incorrect for replicated cache in case if some data node isn't in baseline

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.4
    • Fix Version/s: 2.7
    • Component/s: None
    • Labels:

      Description

      How to reproduce:

      1)Create new server node and activate the cluster (run the StartOneServerAndActivate.java example)
      2)Create another server node. (run the StartSecondServerNode.java example after step 1)
      3)Create client node that will create new replicated cache, put some values and try to get the cache iterator. (run the StartClientNode.java example)

      In this case you should see the log like that:

      Elements in cache: 0
      **************************
      **************************
      **************************
      **************************

      Elements in cache: 1000
      **************************
      **************************
      **************************
      **************************

      Elements in cache: 1000
      **************************
      **************************
      **************************
      **************************

      Elements in cache: 0
      **************************
      **************************
      **************************
      **************************

      Elements in cache: 0
      **************************
      **************************

      It means that sometime we see the cache values and sometime we do not. It happens because second node isn't in the baseline topology. In this case all data was stored to first server node and it's ok.

      The problem here is that when we ask for the iterator then we choose the node that contains the required cache and send to it scan query. At the moment we can choose the node in baseline topology (with data) and empty node. Looks like this behavior should be changed.

      Incorrect logic located at GridCacheQueryAdapter.java at "private Collection<ClusterNode> nodes() throws IgniteCheckedException" method:

      case REPLICATED:
          if (prj != null || part != null)
              return nodes(cctx, prj, part);
      
          if (cctx.affinityNode())
              return Collections.singletonList(cctx.localNode());
      
          Collection<ClusterNode> affNodes = nodes(cctx, null, null); //HERE WE HAVE BOTH NODES AT affNodes
      
          return affNodes.isEmpty() ? affNodes : Collections.singletonList(F.rand(affNodes)) 

       

        Attachments

        1. StartClientNode.java
          4 kB
          Andrey Aleksandrov
        2. StartOneServerAndActivate.java
          3 kB
          Andrey Aleksandrov
        3. StartSecondServerNode.java
          2 kB
          Andrey Aleksandrov

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                aealeksandrov Andrey Aleksandrov
              • Votes:
                1 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: