Uploaded image for project: 'Infinispan'
  1. Infinispan
  2. ISPN-9420

HotRod Transaction Cache is throwing an exception with multiple threads

    XMLWordPrintable

Details

    • Bug
    • Resolution: Not a Bug
    • Major
    • None
    • None
    • None
    • None

    Description

      I created the method `public void testMultiThreadsPessimisticLockMode(Method method)` in the class `TxFunctionalTest`

         public void testMultiThreadsPessimisticLockMode(Method method) throws ExecutionException, InterruptedException {
            final K k1 = kvGenerator.generateKey(method, 1);
            final V v1 = kvGenerator.generateValue(method, 1);
            final V v2 = kvGenerator.generateValue(method, 2);
      
            RemoteCache<K, V> remoteCache = remoteCacheWithForceReturnValue();
            final TransactionManager tm = remoteCache.getTransactionManager();
      
            ExecutorService executorService = Executors.newFixedThreadPool(2);
            Future<?> f1 = executorService.submit(() -> {
               try {
                  TestingUtil.withTx(tm, () -> {
                     V returnValue = remoteCache.put(k1, v1);
                     Thread.sleep(2000);
                     return returnValue;
                  });
               } catch (Exception e) {
                  throw new IllegalStateException(e);
               }
            });
      
            Future<?> f2 = executorService.submit(() -> {
               try {
                  TestingUtil.withTx(tm, () -> {
                     Thread.sleep(500);
                     V returnValue = remoteCache.put(k1, v2);
                     return returnValue;
                  });
               } catch (Exception e) {
                  throw new IllegalStateException(e);
               }
            });
      
            Assert.assertNull(f1.get());
            Assert.assertNull(f2.get());
         }
      

      The integration test is failing due:

      java.util.concurrent.ExecutionException: java.lang.IllegalStateException: javax.transaction.RollbackException: ARJUNA016053: Could not commit transaction.
      
      	at java.util.concurrent.FutureTask.report(FutureTask.java:122)
      	at java.util.concurrent.FutureTask.get(FutureTask.java:192)
      	at org.infinispan.client.hotrod.tx.TxFunctionalTest.testMultiThreadsPessimisticLockMode(TxFunctionalTest.java:473)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
      	at org.testng.internal.MethodInvocationHelper$1.runTestMethod(MethodInvocationHelper.java:196)
      	at org.infinispan.commons.test.TestNGLongTestsHook.run(TestNGLongTestsHook.java:24)
      	at org.testng.internal.MethodInvocationHelper.invokeHookable(MethodInvocationHelper.java:208)
      	at org.testng.internal.Invoker.invokeMethod(Invoker.java:635)
      	at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:816)
      	at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1124)
      	at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
      	at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
      	at org.testng.TestRunner.privateRun(TestRunner.java:774)
      	at org.testng.TestRunner.run(TestRunner.java:624)
      	at org.testng.SuiteRunner.runTest(SuiteRunner.java:359)
      	at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:354)
      	at org.testng.SuiteRunner.privateRun(SuiteRunner.java:312)
      	at org.testng.SuiteRunner.run(SuiteRunner.java:261)
      	at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
      	at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
      	at org.testng.TestNG.runSuitesSequentially(TestNG.java:1215)
      	at org.testng.TestNG.runSuitesLocally(TestNG.java:1140)
      	at org.testng.TestNG.run(TestNG.java:1048)
      	at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:72)
      	at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:123)
      Caused by: java.lang.IllegalStateException: javax.transaction.RollbackException: ARJUNA016053: Could not commit transaction.
      	at org.infinispan.client.hotrod.tx.TxFunctionalTest.lambda$testMultiThreadsPessimisticLockMode$1(TxFunctionalTest.java:457)
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      	at java.lang.Thread.run(Thread.java:748)
      Caused by: javax.transaction.RollbackException: ARJUNA016053: Could not commit transaction.
      	at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1212)
      	at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:126)
      	at org.infinispan.test.TestingUtil.lambda$withTxCallable$11(TestingUtil.java:1529)
      	at org.infinispan.test.TestingUtil.withTx(TestingUtil.java:1507)
      	at org.infinispan.client.hotrod.tx.TxFunctionalTest.lambda$testMultiThreadsPessimisticLockMode$1(TxFunctionalTest.java:451)
      	... 5 more
      Caused by: java.lang.Throwable: setRollbackOnly called from:
      	at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.setRollbackOnly(TransactionImple.java:339)
      	at org.infinispan.client.hotrod.impl.transaction.SyncModeTransactionTable$SynchronizationAdapter.markAsRollback(SyncModeTransactionTable.java:150)
      	at org.infinispan.client.hotrod.impl.transaction.SyncModeTransactionTable$SynchronizationAdapter.beforeCompletion(SyncModeTransactionTable.java:125)
      	at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:76)
      	at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:371)
      	at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:91)
      	at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:162)
      	at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1200)
      	... 9 more
      
      
      

      Attachments

        Issue Links

          Activity

            People

              pruivo@redhat.com Pedro Ruivo
              dlovison@redhat.com Diego Lovison
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: