Description
Torsten Krah opened SPR-11590 and commented
Hi,
i've got a service A which registered a TransactionSynchronization to do stuff in the afterCommit() case.
It calls a service B to index things to lucene.
I've forgot that i did already leveraged the transaction handling to the lucene service B, so i did wonder why nothing happened and no error was thrown.
After debugging i've found that A did register a Synchronization (doAfterCommit) to call B, and B did also register one (doAfterCompletion).
The one which B registered was never called because doAfterCommit is the last trigger to be called and triggerAfterCompletion was already run.
Maybe a check can be added for addSynchronization(), that it throws an Exception, if the afterCompletion trigger is already reached - or at least a log warning would be nice.
Affects: 4.0.2
Issue Links:
- Prevent corrupted ThreadLocals when mis-using triggerAfterCommit [SPR-11761] #16383 Prevent corrupted ThreadLocals when mis-using triggerAfterCommit ("is duplicated by")
- Topic messages are not sent when using transacted JmsTemplate in 'TransactionSynchronization.afterCommit' phase [SPR-16270] #20817 Topic messages are not sent when using transacted JmsTemplate in 'TransactionSynchronization.afterCommit' phase
- Spring does not clean up db connection registered in afterCompletion callback [SPR-15194] #19759 Spring does not clean up db connection registered in afterCompletion callback
- Transaction synchronization hook - beforeCreatePhase [SPR-13724] #18297 Transaction synchronization hook - beforeCreatePhase
- Rollback of transaction participating in nested transaction should not enforce rollback of global transaction [SPR-6568] #11234 Rollback of transaction participating in nested transaction should not enforce rollback of global transaction