1 Reply Latest reply on Aug 6, 2010 4:34 AM by Galder Zamarreño

    Heavy load problem

    Wojciech Durczyński Newbie

      Hello.

      I'm testing Infinispan and have problems with very simple test case. My test program looks like that:

       

      public void doTest(){
          int threads = 40;

       

          LocalThread[] tab = new LocalThread[threads];
          for (int t = 0; t < threads; t++) {
            tab[t] = new LocalThread();
            tab[t].start();

          }
        }

       

      Where LocalThread is a Thread that reads and writes random entries in cache:

       

      class LocalThread extends Thread {

       

          @Override
          public void run() {
            Random los = new Random();
            while (true) {
              int key = los.nextInt(100000);
              int value = los.nextInt(100000);
              int op = los.nextInt(10);
              try {
                if (op<1){
                  cache.put(key, value);
                } else {
                  cache.get(key);
                }
              } catch (Exception e) {
                e.printStackTrace();
              }
            }

          }

        }

       

      Cache is shared between all 40 threads and is created like that:

       

          Configuration config = new Configuration();
          config.setCacheMode(CacheMode.DIST_SYNC);
          DefaultCacheManager manager = new DefaultCacheManager(GlobalConfiguration.getClusteredDefault(), config);
          cache = manager.getCache();

       

      If I run one instance of that program, everything works fine. But launching second instance causes lots of errors:

       

      org.infinispan.CacheException: java.util.concurrent.RejectedExecutionException
          at org.infinispan.remoting.rpc.RpcManagerImpl.invokeRemotely(RpcManagerImpl.java:113)
          at org.infinispan.remoting.rpc.RpcManagerImpl.invokeRemotely(RpcManagerImpl.java:124)
          at org.infinispan.remoting.rpc.RpcManagerImpl.invokeRemotely(RpcManagerImpl.java:229)

      (...)

      Caused by: java.util.concurrent.RejectedExecutionException
          at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:1768)
          at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:767)
          at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:658)

      (...)

       

      or

       

      org.infinispan.util.concurrent.TimeoutException: Unable to acquire lock after [10 seconds] on key [59013] for requestor [Thread[Thread-24,5,main]]! Lock held by [(another thread)]
          at org.infinispan.container.EntryFactoryImpl.acquireLock(EntryFactoryImpl.java:213)
          at org.infinispan.container.EntryFactoryImpl.wrapEntryForWriting(EntryFactoryImpl.java:148)
          at org.infinispan.container.EntryFactoryImpl.wrapEntryForWriting(EntryFactoryImpl.java:106)
          at org.infinispan.interceptors.LockingInterceptor.visitPutKeyValueCommand(LockingInterceptor.java:197)
          at org.infinispan.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:76)
          at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:118)
          at org.infinispan.interceptors.base.CommandInterceptor.handleDefault(CommandInterceptor.java:132)
          at org.infinispan.commands.AbstractVisitor.visitPutKeyValueCommand(AbstractVisitor.java:57)
          at org.infinispan.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:76)
          at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:118)
          at org.infinispan.interceptors.TxInterceptor.enlistWriteAndInvokeNext(TxInterceptor.java:183)
          at org.infinispan.interceptors.TxInterceptor.visitPutKeyValueCommand(TxInterceptor.java:132)
          at org.infinispan.interceptors.DistTxInterceptor.visitPutKeyValueCommand(DistTxInterceptor.java:76)
          at org.infinispan.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:76)
          at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:118)
          at org.infinispan.interceptors.InvocationContextInterceptor.handleAll(InvocationContextInterceptor.java:58)
          at org.infinispan.interceptors.InvocationContextInterceptor.handleDefault(InvocationContextInterceptor.java:39)
          at org.infinispan.commands.AbstractVisitor.visitPutKeyValueCommand(AbstractVisitor.java:57)
          at org.infinispan.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:76)
          at org.infinispan.interceptors.InterceptorChain.invoke(InterceptorChain.java:271)
          at org.infinispan.CacheDelegate.put(CacheDelegate.java:426)
          at org.infinispan.CacheSupport.put(CacheSupport.java:28)
          at InfinispanTest$LocalThread.run(InfinispanTest.java:79)

       

      or

       

      Caused by: org.infinispan.CacheException: Unexpected exception
          at org.infinispan.distribution.JoinTask.performRehash(JoinTask.java:144)
          at org.infinispan.distribution.RehashTask.call(RehashTask.java:52)
          at org.infinispan.distribution.RehashTask.call(RehashTask.java:32)
          at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
          at java.util.concurrent.FutureTask.run(FutureTask.java:138)
          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
          at java.lang.Thread.run(Thread.java:619)
      Caused by: org.infinispan.util.concurrent.TimeoutException: Replication timeout for pcdurczynski-40032
          at org.infinispan.remoting.transport.jgroups.JGroupsTransport.invokeRemotely(JGroupsTransport.java:421)
          at org.infinispan.remoting.rpc.RpcManagerImpl.invokeRemotely(RpcManagerImpl.java:100)
          at org.infinispan.remoting.rpc.RpcManagerImpl.invokeRemotely(RpcManagerImpl.java:124)
          at org.infinispan.remoting.rpc.RpcManagerImpl.invokeRemotely(RpcManagerImpl.java:229)
          at org.infinispan.remoting.rpc.RpcManagerImpl.invokeRemotely(RpcManagerImpl.java:216)
          at org.infinispan.remoting.rpc.RpcManagerImpl.broadcastRpcCommand(RpcManagerImpl.java:199)
          at org.infinispan.distribution.JoinTask.performRehash(JoinTask.java:131)
          ... 7 more

       

      How to configure Infinispan to get rid of these exceptions? Or maybe it's a bug?