2 Replies Latest reply on Jul 22, 2014 3:45 AM by Bingu Shim

    getAsync never finish

    David Novak Newbie

      I have a problem with asynchronous get operation in Ispn-6.0.2. I am using it like this to read a set of values based on their IDs:

       

              for (String string : ids) {

                  cache.getAsync(string).attachListener(new FutureListener<MyClass>() {

                      @Override

                      public void futureDone(Future<MyClass> future) {

                          try {

                              queue.put(future.get());

                          } catch (InterruptedException | ExecutionException | NullPointerException ignore) {     }

                      }               

                  });

              }

       

      When I start to use it more heavily (hundreds of simultaneous reads) it happens to me that (probably all) the reading threads (transport-thread-0  to  -24) got stuck in the "future.get()" method with this stack trace:

      Hidden Source Calls (Unsafe.park)

      LockSupport.park:186

      AbstractQueuedSynchronizer.parkAndCheckInterrupt:834

      AbstractQueuedSynchronizer.doAcquireSharedInterruptibly:994

      AbstractQueuedSynchronizer.acquireSharedInterrptibly:1303

      FutureTask$Sync.innerGet:248

      FutureTask.get:111

      NotifyingFutureAdaptor.get:44

      MyClassMethod$2.futureDone:113


      I understand it like this: the async read was finished because the .futureDone method was called, but the method cannot get to the result from "Future", which is very strange...

       

      Do you have any suggestions what I could do about it? Thank you very much.

        • 1. Re: getAsync never finish
          David Novak Newbie

          Additional information: When I rewrote the code so that it does not use the FutureListener (and thus it is in general less efficient), it works:

                            Future<MyClass> [] futures = new Future [idCount];

                  int counter = 0;

                  for (String string : ids) {

                      futures[counter ++] = cacheToReadFrom.getAsync(string);

                  }

                  for (Future<MyClass> future : futures) {

                      try {

                          queue.put(future.get());

                      } catch (InterruptedException | ExecutionException | NullPointerException ignore) { }

                  }


          It seems that it is some problem in the FutureListener execution when a larger number of threads is used... Or does anybody see any other error? Thank you

          • 2. Re: getAsync never finish
            Bingu Shim Newbie

            Hi David,

             

            I've had the same problem, and found that It is bug in 6.0.2.Final, and it is fixed in version 7.0.0. (The fix is not applied to the 6.0.2)

            I recommend you to use 7.0.0.Aplha5 over 6.0.2.Final, because there are more bugs in 6.0.2.Final which is fixed in 7.0 but not in the 6.0.

             

            See the following link.

            [ISPN-3868] Deadlock in RemoteCache getAsync - JBoss Issue Tracker