-
Notifications
You must be signed in to change notification settings - Fork 8.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature: support XA transaction mode #2381
Conversation
# Conflicts: # server/src/main/java/com/alibaba/fescar/server/coordinator/DefaultCoordinator.java
…try other application on the same resource.
…ormal SELECT SQL
# Conflicts: # test/src/main/java/com/alibaba/fescar/test/DataSourceBasicTest.java
# Conflicts: # rm-datasource/src/main/java/com/alibaba/fescar/rm/datasource/sql/druid/MySQLInsertRecognizer.java # rm-datasource/src/main/java/com/alibaba/fescar/rm/datasource/sql/struct/TableMetaCache.java # test/src/main/java/com/alibaba/fescar/test/DataSourceBasicTest.java
…m BranchSession
…n/branchsession exists while restoring
private static final String mockXid = "127.0.0.1:8091:" + testTid; | ||
private static final long mockBranchId = testTid + 1; | ||
|
||
private static final String pg_jdbcUrl = "jdbc:postgresql://127.0.0.1:5432/postgres"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unable to connect to 127.0.0.1 database, CI occurred a large number of error logs. Please use mock or disable, and remove all printf logs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job~
Codecov Report
@@ Coverage Diff @@
## develop #2381 +/- ##
==========================================
Coverage 50.94% 50.94%
Complexity 2763 2763
==========================================
Files 551 551
Lines 17569 17569
Branches 2063 2063
==========================================
Hits 8950 8950
Misses 7775 7775
Partials 844 844 |
Samples For XA mode: apache/incubator-seata-samples#324 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
看了设计方案,本地跑了demo,无问题
rm-datasource/src/main/java/io/seata/rm/BaseDataSourceResource.java
Outdated
Show resolved
Hide resolved
rm-datasource/src/main/java/io/seata/rm/BaseDataSourceResource.java
Outdated
Show resolved
Hide resolved
rm-datasource/src/main/java/io/seata/rm/BaseDataSourceResource.java
Outdated
Show resolved
Hide resolved
rm-datasource/src/main/java/io/seata/rm/datasource/xa/ConnectionProxyXA.java
Show resolved
Hide resolved
rm-datasource/src/main/java/io/seata/rm/datasource/xa/ExecuteTemplateXA.java
Show resolved
Hide resolved
XAXid xaBranchXid = XAXidBuilder.build(xid, branchId); | ||
Resource resource = dataSourceCache.get(resourceId); | ||
if (resource instanceof AbstractDataSourceProxyXA) { | ||
try (ConnectionProxyXA connectionProxyXA = ((AbstractDataSourceProxyXA)resource).getConnectionForXAFinish(xaBranchXid)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clientA, clientB->TC clientA branchCommit but clientA ->TC channel is bad and XAConn is ok, so TC send request to clientB.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, such cases should be considered in enhancement later.
Just keep the basic logic by now.
return BranchStatus.PhaseTwo_Rollbacked; | ||
} | ||
} catch (XAException xe) { | ||
throw new TransactionException("XA Exception " + xe.getMessage(), xe); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throw exception will result in encode error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merged SQLException and XAException cases.
} | ||
} | ||
} else { | ||
throw new TransactionException("Unknown Resource for XA resource " + resourceId + " " + resource); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throw exception will result in encode error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact, this is a case that SHOULD NEVER happen.
Just merged XAException and SQLException into retryable status.
apache/incubator-seata-samples#324 (comment)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Ⅰ. Describe what this PR did
Provide XA mode to Seata. Issue #2022
Ⅱ. Does this pull request fix one issue?
Ⅲ. Why don't you add test cases (unit test/integration test)?
Ⅳ. Describe how to verify it
all test cases can be found in XAModeTest2
Ⅴ. Special notes for reviews