Uploaded image for project: 'Spring Data Commons'
  1. Spring Data Commons
  2. DATACMNS-1314

ChainedTransactionManager does not handle transaction sychroriazation correctly.


    • Type: Bug
    • Status: Waiting for Review
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Core


      TransactionSynchronization(org.springframework.transaction.support.TransactionSynchronization) has several callback timings, including beforeCommit and afterCommit. And is triggered by AbstractPlatformTransactionManager. 


      Therefore, setting the ChainedTransactionManager with two AbstractPlatformTransactionManagers will result in the following bugs:


      ex) ChainedTransactionManager with DataSourceTransactionManager(implementation of AbstractPlatformTransactionManager) and RabbitTransactionManager(also implementation of AbstractPlatformTransactionManager)


      1. ChainedTransactionManager's commit triggered.
      2. ChainedTransactionManager calls RabbitTransactionManager.commit()
      3. RabbitTransactionManager triggers all beforeCommit synchronizations.
      4. RabbitTransactionManager's commit processed.
      5. RabbitTransactionManager will trigger all afterCommit synchronizations.
        1. Include synchronization for DataSourceTransactionManager.
        2. And DataSourceTransactionManager's commit not processed yet.
      6. RabbitTransactionManager will cleanup synchronizations.
      7. DataSourceTransactionManager commit processed without any synchronizations.


      I think following solution:

      • ChainedTransactionManager also inherit AbstractPlatformTransactionManager.
      • And ChainedTransactionManager call nested transaction managers doGetTransaction(), isExistingTransaction() (template methods required by AbstractPlatformTransactionManager) for handling transaction. These template methods does not trigger any transaction synchronizations. 
      • Now ChainedTransactionManager calls transaction synchronizations.
      • In addition to, ChainedTransactionManager will handle transaction propagation correctly.


      This solution has two issues.

      1. Template methods of AbstractPlatformTransactionManager is protected method.
        1. Using java reflections for invoking methods.
      2. Nested transaction manager may not be an implementation of the AbstractPlatformTransactionManager.
        1. I suggest ChainableTransactionManager interface.





            • Assignee:
              olivergierke Oliver Drotbohm
              thewhite Byeongguk Gim
              Last updater:
              Oliver Drotbohm
            • Votes:
              0 Vote for this issue
              3 Start watching this issue


              • Created: