[infinispan-issues] [JBoss JIRA] (ISPN-3868) Deadlock in RemoteCache getAsync

Radim Vansa (JIRA) issues at jboss.org
Mon Jan 6 08:55:33 EST 2014


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

Radim Vansa updated ISPN-3868:
------------------------------

    Description: 
Here is the implementation of remoteCahe.getAsync() :
{code}
 public NotifyingFuture<V> getAsync(final K key) {
      assertRemoteCacheManagerIsStarted();
      final NotifyingFutureImpl<V> result = new NotifyingFutureImpl<V>();
      Future<V> future = executorService.submit(new Callable<V>() {
         @Override
         public V call() throws Exception {
            V toReturn = get(key);
            result.notifyFutureCompletion();
            return toReturn;
         }
      });
      result.setExecuting(future);
      return result;
   }
{code}
2 problems here :

1. Callable's call method might be called BEFORE calling client had a chance to add listener (i.e. getAsync is not returned yet), in this case its' listener futureDone method  will never be called.

2. Even case #1 has not happened and  notifyFutureCompletion is called on listener, but the future is not  resolved yet : "call" has not returned, that's why the future that is passed to listener is  not resolved, and calling future.get from listener blocks forever.


  was:
Here is the implementation of remoteCahe.getAsync() :

 public NotifyingFuture<V> getAsync(final K key) {
      assertRemoteCacheManagerIsStarted();
      final NotifyingFutureImpl<V> result = new NotifyingFutureImpl<V>();
      Future<V> future = executorService.submit(new Callable<V>() {
         @Override
         public V call() throws Exception {
            V toReturn = get(key);
            result.notifyFutureCompletion();
            return toReturn;
         }
      });
      result.setExecuting(future);
      return result;
   }
2 problems here :

1. Callable's call method might be called BEFORE calling client had a chance to add listener (i.e. getAsync is not returned yet), in this case its' listener futureDone method  will never be called.

2. Even case #1 has not happened and  notifyFutureCompletion is called on listener, but the future is not  resolved yet : "call" has not returned, that's why the future that is passed to listener is  not resolved, and calling future.get from listener blocks forever.



    
> Deadlock in RemoteCache getAsync
> --------------------------------
>
>                 Key: ISPN-3868
>                 URL: https://issues.jboss.org/browse/ISPN-3868
>             Project: Infinispan
>          Issue Type: Bug
>          Components: Core API
>    Affects Versions: 6.0.0.Final
>         Environment: RemoteCahe component of 6.0.0.Final 
>            Reporter: Alexander Furer
>            Assignee: Mircea Markus
>            Priority: Critical
>              Labels: remote
>
> Here is the implementation of remoteCahe.getAsync() :
> {code}
>  public NotifyingFuture<V> getAsync(final K key) {
>       assertRemoteCacheManagerIsStarted();
>       final NotifyingFutureImpl<V> result = new NotifyingFutureImpl<V>();
>       Future<V> future = executorService.submit(new Callable<V>() {
>          @Override
>          public V call() throws Exception {
>             V toReturn = get(key);
>             result.notifyFutureCompletion();
>             return toReturn;
>          }
>       });
>       result.setExecuting(future);
>       return result;
>    }
> {code}
> 2 problems here :
> 1. Callable's call method might be called BEFORE calling client had a chance to add listener (i.e. getAsync is not returned yet), in this case its' listener futureDone method  will never be called.
> 2. Even case #1 has not happened and  notifyFutureCompletion is called on listener, but the future is not  resolved yet : "call" has not returned, that's why the future that is passed to listener is  not resolved, and calling future.get from listener blocks forever.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the infinispan-issues mailing list