RollbackError while rolling back

20 views
Skip to first unread message

Chinni Krishna

unread,
May 22, 2015, 8:42:45 AM5/22/15
to scala-stm-e...@googlegroups.com
Hi,

I am running a set of instructions in STM.atomic block. There are some conflict transaction and the trasaction would be rolled back. Sometimes I get the rollbackerror exception while the transaction is rolling back. I can catch the throwable error and retry the transaction again. When the transaction is retried then it works correctly. In what circumstances will we get RollBackError. 

My Sample code 

 STM.atomic(new Runnable()
            {
               @Override public void run()
               {
                  scope.startTransaction();

                  try
                  {
                     returnValue = jsScriptEngine.executeScript(scope, new StringReader(script));
                  }
                  catch (RuntimeException rte)
                  {
                     //get actual exception from rte and throw it from here
                     Throwable cause = rte.getCause();

                     if (cause != null)
                     {
                        setException(cause);
                     }
                     else
                     {
                        setException(rte);
                     }
                  }

                  STM.afterCommit(new Runnable()
                     {
                        @Override public void run()
                        {
                           try
                           {
                              scope.commitTransaction();
                           }
                
                           catch (DatabaseException e)
                           {
                              e.printStackTrace();

                           }
                        }

   
                     });
               }
            });

The above code runs in the run method of thread. 

Does anyone have any clues ?

-Chinni. 
Reply all
Reply to author
Forward
0 new messages