Skip to content

feature: Reuse connection to merge branch transactions#7509

Merged
funky-eyes merged 22 commits intoapache:2.xfrom
PeppaO:combine
Aug 13, 2025
Merged

feature: Reuse connection to merge branch transactions#7509
funky-eyes merged 22 commits intoapache:2.xfrom
PeppaO:combine

Conversation

@PeppaO
Copy link
Contributor

@PeppaO PeppaO commented Jul 9, 2025

  • I have registered the PR changes.

Ⅰ. Describe what this PR did

fixes #7357

Ⅱ. Does this pull request fix one issue?

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

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

@codecov
Copy link

codecov bot commented Jul 9, 2025

Codecov Report

❌ Patch coverage is 50.79365% with 62 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.34%. Comparing base (f8e0bd5) to head (0883c9a).
⚠️ Report is 1 commits behind head on 2.x.

Files with missing lines Patch % Lines
...andler/CombineTransactionalInterceptorHandler.java 32.60% 27 Missing and 4 partials ⚠️
.../parser/CombineTransactionalInterceptorParser.java 56.66% 10 Missing and 3 partials ⚠️
...ache/seata/rm/datasource/xa/ConnectionProxyXA.java 27.27% 5 Missing and 3 partials ⚠️
...ache/seata/rm/datasource/xa/DataSourceProxyXA.java 41.66% 5 Missing and 2 partials ⚠️
...rm/datasource/combine/CombineConnectionHolder.java 89.47% 1 Missing and 1 partial ⚠️
...ava/org/apache/seata/core/context/RootContext.java 83.33% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##                2.x    #7509      +/-   ##
============================================
- Coverage     61.37%   61.34%   -0.04%     
- Complexity      658      662       +4     
============================================
  Files          1308     1311       +3     
  Lines         49443    49567     +124     
  Branches       5811     5834      +23     
============================================
+ Hits          30346    30406      +60     
- Misses        16390    16440      +50     
- Partials       2707     2721      +14     
Files with missing lines Coverage Δ
...tion/tx/api/interceptor/InvocationHandlerType.java 100.00% <100.00%> (ø)
...ava/org/apache/seata/core/context/RootContext.java 82.35% <83.33%> (+0.09%) ⬆️
...rm/datasource/combine/CombineConnectionHolder.java 89.47% <89.47%> (ø)
...ache/seata/rm/datasource/xa/DataSourceProxyXA.java 69.49% <41.66%> (-7.60%) ⬇️
...ache/seata/rm/datasource/xa/ConnectionProxyXA.java 49.00% <27.27%> (-0.74%) ⬇️
.../parser/CombineTransactionalInterceptorParser.java 56.66% <56.66%> (ø)
...andler/CombineTransactionalInterceptorHandler.java 32.60% <32.60%> (ø)

... 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.

@YongGoose
Copy link
Member

Please update all comments written in Chinese to English.

@PeppaO
Copy link
Contributor Author

PeppaO commented Jul 10, 2025

Please update all comments written in Chinese to English.

done

mvn spotless:apply

done

@PeppaO PeppaO requested a review from funky-eyes July 10, 2025 05:37
</dependency>

<dependency>
<groupId>org.springframework</groupId>
Copy link
Contributor

Choose a reason for hiding this comment

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

It should not rely on Spring, but instead refer to the existing proxy approach and use byte-buddy for proxying.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@funky-eyes funky-eyes added this to the 2.6.0 milestone Aug 4, 2025
@funky-eyes funky-eyes added type: feature Category issues or prs related to feature request. module/rm-datasource rm-datasource module module/intergration-tx-api intergration-tx-api labels Aug 4, 2025
import java.util.concurrent.ConcurrentHashMap;

public class CombineConnectionHolder {
private static final ThreadLocal<Map<String, Map<Object, ConnectionProxyXA>>> CONNECTION_HOLDER =
Copy link
Contributor

Choose a reason for hiding this comment

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

Why use ConcurrentHashMap? Will there be concurrent situations?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think there may be asynchronous or parallel branches.


@Override
public void rollback() throws SQLException {
if (combine) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If a rollback is issued during a two-phase commit, would there be any issues if the branch is still running?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There may be a situation where the connection is not reset and the process is automatically submitted. This has been resolved

Copy link
Contributor

@funky-eyes funky-eyes left a comment

Choose a reason for hiding this comment

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

LGTM

@funky-eyes funky-eyes merged commit a9e19b7 into apache:2.x Aug 13, 2025
12 of 14 checks passed
slievrly pushed a commit to slievrly/fescar that referenced this pull request Oct 21, 2025
* @throws XAException XAException
*/
public void xaRollback(XAXid xaXid) throws XAException {
xaEnd(xaXid, XAResource.TMFAIL);

Choose a reason for hiding this comment

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

Hi! Can you explain a bit why this xaEnd() is added?

I'm experiencing issues with this line ending a MySQL branch, where the DB throws an exception saying that end is not allowed when the branch is in a NON-EXISTING state.
Without this line, everything works just fine since Seata 2.0.0.

YvCeung pushed a commit to YvCeung/incubator-seata that referenced this pull request Dec 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module/intergration-tx-api intergration-tx-api module/rm-datasource rm-datasource module type: feature Category issues or prs related to feature request.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants