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.
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();
}
}
});
}
});