Skip to content

bugfix: use per-branch qualified gtrid in XA mode for DM - #8312

Open
whaon wants to merge 3 commits into
apache:2.xfrom
whaon:2.x.new
Open

whaon wants to merge 3 commits into
apache:2.xfrom
whaon:2.x.new

Conversation

@whaon

@whaon whaon commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Ⅰ. Describe what this PR did

DM rejects a new xa start with XAER_RMERR while an in-doubt (prepared) branch of the same gtrid exists on the instance, so two branches of one Seata global transaction cannot hit the same DM instance in XA mode.

For dbType=dm, qualify the XA gtrid with the branch id (gtrid = xid + "-" + branchId, formatId 9753) so every branch owns a distinct gtrid. The legacy format (formatId 9752, gtrid = xid) is kept byte-for-byte for every other database.

Ⅱ. Does this pull request fix one issue?

fix #8310

Ⅲ. Why don't you add test cases (unit test/integration test)?

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

@whaon whaon mentioned this pull request Oct 20, 2026
2 tasks
@funky-eyes

Copy link
Copy Markdown
Contributor
image Please make sure the email address in your Git commits matches the one you used to submit the PR.

@github-actions github-actions Bot added the type: bug Category issues or prs related to bug. label Oct 20, 2026
@whaon

whaon commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

image Please make sure the email address in your Git commits matches the one you used to submit the PR.

done

@funky-eyes funky-eyes left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed HEAD 88e3e16dafa8b4ba83ccedcf415bb337b95f6275 against merge base a9b03977be324c170741ebc37d797d5bfd159552.

Requesting changes for the two inline issues: valid long XIDs can fail after branch registration and remain unresolvable through the new encoder, and pre-upgrade DM prepared branches cannot be reconstructed with their original physical XA identity.

Please also provide a minimal real-DM reproduction or integration test for #8310. The reported stack fails in DmdbXAResource.end(), whereas the PR describes rejection in start(). That does not disprove the proposed cause, but the current byte-array tests do not establish it. Compare shared-gtrid/different-bqual branches against the new encoding on the same DM instance, record the failing XA call/error code and server/driver versions, and verify commit and rollback, including RM restart.

Validation: compiled the PR's actual Xid sources, executed all 8 existing methods in XAXidBuilderTest and XABranchXidTest with their JUnit assertions (all passed), reproduced the 62-byte-to-81-byte IPv6 failure, and checked that legacy prepare/new-DM phase-two produce different physical Xid tuples. No real DM database or full Maven suite was run. The multi-schema resourceId collision predates this PR and is not included as a regression finding.

@whaon
whaon requested a review from funky-eyes October 21, 2026 01:04
@codecov

codecov Bot commented Nov 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.04651% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.87%. Comparing base (cba73e1) to head (24a7509).

Files with missing lines Patch % Lines
...ache/seata/rm/datasource/xa/ConnectionProxyXA.java 77.77% 1 Missing and 3 partials ⚠️
...org/apache/seata/rm/datasource/xa/XABranchXid.java 90.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##                2.x    #8312      +/-   ##
============================================
+ Coverage     79.84%   79.87%   +0.03%     
+ Complexity     1162     1160       -2     
============================================
  Files          1400     1400              
  Lines         53011    53046      +35     
  Branches       6349     6357       +8     
============================================
+ Hits          42325    42371      +46     
+ Misses         7729     7723       -6     
+ Partials       2957     2952       -5     
Files with missing lines Coverage Δ
...ache/seata/rm/datasource/xa/ResourceManagerXA.java 89.04% <100.00%> (+0.15%) ⬆️
...rg/apache/seata/rm/datasource/xa/XAXidBuilder.java 100.00% <100.00%> (ø)
...org/apache/seata/rm/datasource/xa/XABranchXid.java 75.80% <90.00%> (+7.62%) ⬆️
...ache/seata/rm/datasource/xa/ConnectionProxyXA.java 89.49% <77.77%> (-0.80%) ⬇️

... and 11 files with indirect coverage changes

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: bug Category issues or prs related to bug.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error in Dameng when using different schema with same database (ip and port are the same)

2 participants