[infinispan-issues] [JBoss JIRA] (ISPN-4493) Future.get() never finish after getAsync() with FutureListener

Dan Berindei (JIRA) issues at jboss.org
Mon Jul 28 14:29:29 EDT 2014


     [ https://issues.jboss.org/browse/ISPN-4493?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dan Berindei updated ISPN-4493:
-------------------------------

    Description: 
I think I have found 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:

{code:java} 
        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) {     }
                }               
            });
        }
{code}

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:
{noformat}
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
SomeMyClass$2.futureDone:113
{noformat}

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...

When I rewrote the code so that it does not use the FutureListener (and thus it is in general less efficient), it works:
{code:java}
        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) { }
        }
{code}

  was:
I think I have found 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
SomeMyClass$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...

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) { }
        }



> Future.get() never finish after getAsync() with FutureListener
> --------------------------------------------------------------
>
>                 Key: ISPN-4493
>                 URL: https://issues.jboss.org/browse/ISPN-4493
>             Project: Infinispan
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: Core
>    Affects Versions: 6.0.2.Final
>         Environment: Using a single Ispn node, using single file persistance
>            Reporter: David Novak
>            Assignee: Dan Berindei
>            Priority: Minor
>
> I think I have found 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:
> {code:java} 
>         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) {     }
>                 }               
>             });
>         }
> {code}
> 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:
> {noformat}
> 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
> SomeMyClass$2.futureDone:113
> {noformat}
> 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...
> When I rewrote the code so that it does not use the FutureListener (and thus it is in general less efficient), it works:
> {code:java}
>         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) { }
>         }
> {code}



--
This message was sent by Atlassian JIRA
(v6.2.6#6264)


More information about the infinispan-issues mailing list