Clemens Schneider opened SPR-6568 and commented
In my scenario, I have a global transaction (PROPAGATION_REQUIRED) in which I start a nested transaction (PROPAGATION_NESTED) in which I start another transaction (PROPAGATION_REQUIRED). A RuntimeException is thrown inside the most inner transaction and is caught inside the most outer transaction. Now I would expect that only the most inner and the nested transaction get rolled back to its savepoints but instead the whole transaction gets marked as rollbackOnly which gets me an UnexpectedRollbackException.
A fix would be to set the globalRollbackOnParticipationFailure flag of the platform transaction manager to false, but in general, this behaviour is desired in our application.
Wouldn't it be possible somehow to check in the inner transaction if there is another nested transaction active and if this is the case, to not mark the transaction as rollbackOnly?
Simply put:
PROPAGATION_REQUIRED {
try {
PROPAGATION_NESTED {
PROPAGATION_REQUIRED {
throws RuntimeException(); // causes whole transaction to rollback
}
}
} catch (RuntimeException) {
// handle here without re-throwing
}
}
Affects: 2.5.5
Issue Links:
Referenced from: commits 0f51ff5
3 votes, 5 watchers
Clemens Schneider opened SPR-6568 and commented
In my scenario, I have a global transaction (PROPAGATION_REQUIRED) in which I start a nested transaction (PROPAGATION_NESTED) in which I start another transaction (PROPAGATION_REQUIRED). A RuntimeException is thrown inside the most inner transaction and is caught inside the most outer transaction. Now I would expect that only the most inner and the nested transaction get rolled back to its savepoints but instead the whole transaction gets marked as rollbackOnly which gets me an UnexpectedRollbackException.
A fix would be to set the globalRollbackOnParticipationFailure flag of the platform transaction manager to false, but in general, this behaviour is desired in our application.
Wouldn't it be possible somehow to check in the inner transaction if there is another nested transaction active and if this is the case, to not mark the transaction as rollbackOnly?
Simply put:
PROPAGATION_REQUIRED {
try {
PROPAGATION_NESTED {
PROPAGATION_REQUIRED {
throws RuntimeException(); // causes whole transaction to rollback
}
}
} catch (RuntimeException) {
// handle here without re-throwing
}
}
Affects: 2.5.5
Issue Links:
Referenced from: commits 0f51ff5
3 votes, 5 watchers