ballerina-lang
ballerina-lang copied to clipboard
Fix XAER_RMFAIL error on transaction rollback
Purpose
Handle proper signaling of transaction completion to XA Resources when aborting a transaction as invoking xa_rollback() without signaling the end of the transaction's work triggers an XAER_RMFAIL: The command cannot be executed when the global transaction is in the ACTIVE state error.
Fixes #41948
Approach
Added the boolean flag abortOnly to track the transaction's abort status within the endXATransaction() method. This flag indicates whether the transaction is set for abort or not, providing clarity on the success or failure of work within the transaction context. If the transaction is in the process of aborting, the xa_end() method is invoked on the XA Resource using the TMFAIL flag. This flag indicates the failure of a portion of work within the transaction, effectively marking the transaction as rollback-only. However, in cases where the transaction is proceeding normally without an abort condition, the TMSUCCESS flag is used as per normal operation.
Modified the transaction handling sequence by introducing a call to endXATransaction before invoking notifyAbort. This change guarantees explicit signaling of the transaction's completion before initiating the rollback phase. It prevents XAER_RMFAIL error during xa_rollback() on the XA Resource.
Samples
Provide high-level details about the samples related to this feature.
Remarks
List any other known issues, related PRs, TODO items, or any other notes related to the PR.
Check List
- [x] Read the Contributing Guide
- [ ] Updated Change Log
- [ ] Checked Tooling Support (#<Issue Number>)
- [ ] Added necessary tests
- [ ] Unit Tests
- [ ] Spec Conformance Tests
- [ ] Integration Tests
- [ ] Ballerina By Example Tests
- [ ] Increased Test Coverage
- [ ] Added necessary documentation
- [ ] API documentation
- [ ] Module documentation in Module.md files
- [ ] Ballerina By Examples
Codecov Report
Attention: Patch coverage is 0% with 3 lines in your changes are missing coverage. Please review.
Project coverage is 78.57%. Comparing base (
148286d) to head (68fcdc5). Report is 36 commits behind head on master.
:exclamation: Current head 68fcdc5 differs from pull request most recent head d5e9ab2. Consider uploading reports for the commit d5e9ab2 to get more accurate results
| Files | Patch % | Lines |
|---|---|---|
| ...ntime/transactions/TransactionResourceManager.java | 0.00% | 2 Missing :warning: |
| .../runtime/transactions/TransactionLocalContext.java | 0.00% | 1 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## master #41955 +/- ##
============================================
+ Coverage 76.80% 78.57% +1.77%
- Complexity 53972 63155 +9183
============================================
Files 2924 2912 -12
Lines 203952 240083 +36131
Branches 26597 36832 +10235
============================================
+ Hits 156638 188637 +31999
- Misses 38777 42544 +3767
- Partials 8537 8902 +365
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the stale label is removed or commented.
This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the stale label is removed or commented.
This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the stale label is removed or commented.
This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the stale label is removed or commented.