Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
-
None
Description
Forward compensation will retry after the call fails until the maximum number of retries is exceeded. It calls the reverse compensate applyTo method with each retry. This will cause multiple TxStartedEvent and TxAbortEvent to be sent. Test case [1] proves this.
For example, retries=2, the first failure, and the second success, Alpha will receive the following events
TxStartedEvent-tx1 (first)
TxAbortEvent-tx1(This will trigger the compensation operation)
TxStartedEvent-tx1 (second)
TxEndedEvent-tx1 (tx1 will be submitted)
I suggest sending the TxAbortEvent event only if the last forward retry failed. The modified event list looks as follows
Example 1: retries=3 and retry all failed
TxStartedEvent-tx1
TxStartedEvent-tx1
TxStartedEvent-tx1
TxAbortEvent-tx1(Trigger compensation operation)
Example 2: retries=3 and last retry succeeded
TxStartedEvent-tx1
TxStartedEvent-tx1
TxStartedEvent-tx1
TxEndedEvent-tx1
[1] https://github.com/apache/servicecomb-pack/blob/133a2fa7247b2ba00a380762a38369849390560e/omega/omega-transaction/src/test/java/org/apache/servicecomb/pack/omega/transaction/TransactionAspectTest.java#L309 tx/src/test/java/org/apache/servicecomb/pack/omega/transaction/spring/TransactionInterceptionTest.java#L199
[3] https://github.com/apache/servicecomb-pack/blob/133a2fa7247b2ba00a380762a38369849390560e/omega/omega-transaction/src/test/java/org/apache/servicecomb/pack/omega/transaction/TransactionAspectTest.java#L353
Attachments
Issue Links
- links to