You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@seata.apache.org by "xiaoxiangyeyu0 (via GitHub)" <gi...@apache.org> on 2025/01/11 04:27:08 UTC

[PR] Fix bug in https://github.com/apache/incubator-seata/issues/7100 [incubator-seata]

xiaoxiangyeyu0 opened a new pull request, #7102:
URL: https://github.com/apache/incubator-seata/pull/7102

   <!-- Please make sure you have read and understood the contributing guidelines -->
   
   - [ ] I have registered the PR [changes](../changes).
   
   ### Ⅰ. Describe what this PR did
   
   
   ### Ⅱ. Does this pull request fix one issue?
   <!-- If that, add "fixes #xxx" below in the next line, for example, fixes #97. -->
   
   
   ### Ⅲ. Why don't you add test cases (unit test/integration test)? 
   
   
   ### Ⅳ. Describe how to verify it
   
   
   ### Ⅴ. Special notes for reviews
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] bugfix: modify XA mode pre commit transaction from commit phase to before close phase [incubator-seata]

Posted by "xiaoxiangyeyu0 (via GitHub)" <gi...@apache.org>.
xiaoxiangyeyu0 commented on PR #7102:
URL: https://github.com/apache/incubator-seata/pull/7102#issuecomment-2658700011

   pr已登记


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] bugfix: modify XA mode pre commit transaction from commit phase to before close phase [incubator-seata]

Posted by "xiaoxiangyeyu0 (via GitHub)" <gi...@apache.org>.
xiaoxiangyeyu0 commented on code in PR #7102:
URL: https://github.com/apache/incubator-seata/pull/7102#discussion_r1916575336


##########
rm-datasource/src/main/java/org/apache/seata/rm/datasource/xa/ConnectionProxyXA.java:
##########
@@ -117,6 +117,10 @@ private void xaEnd(XAXid xaXid, int flags) throws XAException {
         if (!xaEnded) {
             xaResource.end(xaXid, flags);
             xaEnded = true;
+        } else {
+            if (flags == XAResource.TMSUCCESS) {

Review Comment:
   xaEnded为false的时候会xaResource.end,这里flags == XAResource.TMSUCCESS是为了事务2继续用这个connection commit时能够xaResource.end,因为第一次commit把xaEnded置为true了



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] bugfix: modify XA mode pre commit transaction from commit phase to before close phase [incubator-seata]

Posted by "xiaoxiangyeyu0 (via GitHub)" <gi...@apache.org>.
xiaoxiangyeyu0 commented on code in PR #7102:
URL: https://github.com/apache/incubator-seata/pull/7102#discussion_r1912890780


##########
rm-datasource/src/main/java/org/apache/seata/rm/datasource/xa/ConnectionProxyXA.java:
##########
@@ -324,13 +308,41 @@ private void checkTimeout(Long now) throws XAException {
 
     @Override
     public synchronized void close() throws SQLException {
-        rollBacked = false;
-        if (isHeld() && shouldBeHeld()) {
-            // if kept by a keeper, just hold the connection.
-            return;
+        try {
+            if (xaEnded) {

Review Comment:
   接着发sql最终还是会调用commit方法,xaEnded会被置为true,close时依然会进行prepare



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] Fix bug in https://github.com/apache/incubator-seata/issues/7100 [incubator-seata]

Posted by "xingfudeshi (via GitHub)" <gi...@apache.org>.
xingfudeshi commented on PR #7102:
URL: https://github.com/apache/incubator-seata/pull/7102#issuecomment-2586083775

   I suggest making the title more specific to better describe the bug that has been fixed.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] bugfix: modify XA mode pre commit transaction from commit phase to before close phase [incubator-seata]

Posted by "xiaoxiangyeyu0 (via GitHub)" <gi...@apache.org>.
xiaoxiangyeyu0 commented on code in PR #7102:
URL: https://github.com/apache/incubator-seata/pull/7102#discussion_r1916850524


##########
rm-datasource/src/main/java/org/apache/seata/rm/datasource/xa/ConnectionProxyXA.java:
##########
@@ -117,6 +117,10 @@ private void xaEnd(XAXid xaXid, int flags) throws XAException {
         if (!xaEnded) {
             xaResource.end(xaXid, flags);
             xaEnded = true;
+        } else {
+            if (flags == XAResource.TMSUCCESS) {

Review Comment:
   xaEnded默认是false,第一次调用xaEnd方法会把xaEnded置为true



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] bugfix: modify XA mode pre commit transaction from commit phase to before close phase [incubator-seata]

Posted by "funky-eyes (via GitHub)" <gi...@apache.org>.
funky-eyes commented on code in PR #7102:
URL: https://github.com/apache/incubator-seata/pull/7102#discussion_r1916136541


##########
rm-datasource/src/main/java/org/apache/seata/rm/datasource/xa/ConnectionProxyXA.java:
##########
@@ -117,6 +117,10 @@ private void xaEnd(XAXid xaXid, int flags) throws XAException {
         if (!xaEnded) {
             xaResource.end(xaXid, flags);
             xaEnded = true;
+        } else {
+            if (flags == XAResource.TMSUCCESS) {

Review Comment:
   为什么只有TMSUCCESS才需要end?join进来的不再end了吗?
   假设事务1 commit,事务2继续用这个connection commit(等于先join)走到这个xaend,就不执行xaend了?还有rollback的时候会走到这个xaend方法,此时rollback不直接end,直接进行rollback吗?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] Fix bug in https://github.com/apache/incubator-seata/issues/7100 [incubator-seata]

Posted by "xiaoxiangyeyu0 (via GitHub)" <gi...@apache.org>.
xiaoxiangyeyu0 commented on PR #7102:
URL: https://github.com/apache/incubator-seata/pull/7102#issuecomment-2586100981

   Description added


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] bugfix: modify XA mode pre commit transaction from commit phase to before close phase [incubator-seata]

Posted by "funky-eyes (via GitHub)" <gi...@apache.org>.
funky-eyes commented on code in PR #7102:
URL: https://github.com/apache/incubator-seata/pull/7102#discussion_r1912788269


##########
rm-datasource/src/main/java/org/apache/seata/rm/datasource/xa/ConnectionProxyXA.java:
##########
@@ -223,34 +233,12 @@ public synchronized void commit() throws SQLException {
             throw new SQLException("should NOT commit on an inactive session", SQLSTATE_XA_NOT_END);
         }
         try {
-            // XA End: Success
-            try {
-                end(XAResource.TMSUCCESS);
-            } catch (SQLException sqle) {
-                // Rollback immediately before the XA Branch Context is deleted.
-                String xaBranchXid = this.xaBranchXid.toString();
-                rollback();
-                throw new SQLException("Branch " + xaBranchXid + " was rollbacked on committing since " + sqle.getMessage(), SQLSTATE_XA_NOT_END, sqle);
-            }
-            long now = System.currentTimeMillis();
-            checkTimeout(now);
-            setPrepareTime(now);
-            int prepare = xaResource.prepare(xaBranchXid);
-            // Based on the four databases: MySQL (8), Oracle (12c), Postgres (16), and MSSQL Server (2022),
-            // only Oracle has read-only optimization; the others do not provide read-only feedback.
-            // Therefore, the database type check can be eliminated here.
-            if (prepare == XAResource.XA_RDONLY) {
-                // Branch Report to TC: RDONLY
-                reportStatusToTC(BranchStatus.PhaseOne_RDONLY);
-            }
-        } catch (XAException xe) {
-            // Branch Report to TC: Failed
-            reportStatusToTC(BranchStatus.PhaseOne_Failed);
-            throw new SQLException(
-                "Failed to end(TMSUCCESS)/prepare xa branch on " + xid + "-" + xaBranchXid.getBranchId() + " since " + xe
-                    .getMessage(), xe);
+            xaEnd(xaBranchXid, XAResource.TMSUCCESS);

Review Comment:
   ```suggestion
               end(XAResource.TMSUCCESS);
   ```



##########
rm-datasource/src/main/java/org/apache/seata/rm/datasource/xa/ConnectionProxyXA.java:
##########
@@ -324,13 +308,41 @@ private void checkTimeout(Long now) throws XAException {
 
     @Override
     public synchronized void close() throws SQLException {
-        rollBacked = false;
-        if (isHeld() && shouldBeHeld()) {
-            // if kept by a keeper, just hold the connection.
-            return;
+        try {
+            if (xaEnded) {
+                termination();
+                long now = System.currentTimeMillis();
+                checkTimeout(now);
+                setPrepareTime(now);
+                int prepare = xaResource.prepare(xaBranchXid);

Review Comment:
   如果走了rollback的事务不需要prepare,直接上报一阶段失败即可
   If the transaction that has gone rollback does not need to be prepared, it can directly report the failure of the first stage



##########
rm-datasource/src/main/java/org/apache/seata/rm/datasource/xa/ConnectionProxyXA.java:
##########
@@ -324,13 +308,41 @@ private void checkTimeout(Long now) throws XAException {
 
     @Override
     public synchronized void close() throws SQLException {
-        rollBacked = false;
-        if (isHeld() && shouldBeHeld()) {
-            // if kept by a keeper, just hold the connection.
-            return;
+        try {
+            if (xaEnded) {
+                termination();

Review Comment:
   我认为prepare这块的逻辑不需要termination
   I don't think the logic of preparing this piece needs termination



##########
rm-datasource/src/main/java/org/apache/seata/rm/datasource/xa/ConnectionProxyXA.java:
##########
@@ -223,34 +233,12 @@ public synchronized void commit() throws SQLException {
             throw new SQLException("should NOT commit on an inactive session", SQLSTATE_XA_NOT_END);
         }
         try {
-            // XA End: Success
-            try {
-                end(XAResource.TMSUCCESS);
-            } catch (SQLException sqle) {
-                // Rollback immediately before the XA Branch Context is deleted.
-                String xaBranchXid = this.xaBranchXid.toString();
-                rollback();
-                throw new SQLException("Branch " + xaBranchXid + " was rollbacked on committing since " + sqle.getMessage(), SQLSTATE_XA_NOT_END, sqle);
-            }
-            long now = System.currentTimeMillis();
-            checkTimeout(now);
-            setPrepareTime(now);
-            int prepare = xaResource.prepare(xaBranchXid);
-            // Based on the four databases: MySQL (8), Oracle (12c), Postgres (16), and MSSQL Server (2022),
-            // only Oracle has read-only optimization; the others do not provide read-only feedback.
-            // Therefore, the database type check can be eliminated here.
-            if (prepare == XAResource.XA_RDONLY) {
-                // Branch Report to TC: RDONLY
-                reportStatusToTC(BranchStatus.PhaseOne_RDONLY);
-            }
-        } catch (XAException xe) {
-            // Branch Report to TC: Failed
-            reportStatusToTC(BranchStatus.PhaseOne_Failed);
-            throw new SQLException(
-                "Failed to end(TMSUCCESS)/prepare xa branch on " + xid + "-" + xaBranchXid.getBranchId() + " since " + xe
-                    .getMessage(), xe);
+            xaEnd(xaBranchXid, XAResource.TMSUCCESS);
+        } catch (XAException e) {
+            throw new SQLException("Failed to end(TMSUCCESS) xa branch on " + xid + "-" + xaBranchXid.getBranchId()
+                    + " since " + e.getMessage(), e);
         } finally {
-            cleanXABranchContext();
+            xaActive = false;

Review Comment:
   这个改成false后,如果通过setAutoCommit触发commit时要怎么办?
   After changing this to false, what if the commit is triggered by setAutoCommit?



##########
rm-datasource/src/main/java/org/apache/seata/rm/datasource/xa/ConnectionProxyXA.java:
##########
@@ -324,13 +308,41 @@ private void checkTimeout(Long now) throws XAException {
 
     @Override
     public synchronized void close() throws SQLException {
-        rollBacked = false;
-        if (isHeld() && shouldBeHeld()) {
-            // if kept by a keeper, just hold the connection.
-            return;
+        try {
+            if (xaEnded) {

Review Comment:
   end后的xa事务应该是可以join的,只要没有进入prepare阶段,如果我手动commit或rollback,再接着发sql,这里被标识成了xaended,如何进行prepare?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] bugfix: modify XA mode pre commit transaction from commit phase to before close phase [incubator-seata]

Posted by "funky-eyes (via GitHub)" <gi...@apache.org>.
funky-eyes commented on code in PR #7102:
URL: https://github.com/apache/incubator-seata/pull/7102#discussion_r1919635341


##########
rm-datasource/src/main/java/org/apache/seata/rm/datasource/xa/ConnectionProxyXA.java:
##########
@@ -117,6 +117,10 @@ private void xaEnd(XAXid xaXid, int flags) throws XAException {
         if (!xaEnded) {
             xaResource.end(xaXid, flags);
             xaEnded = true;
+        } else {
+            if (flags == XAResource.TMSUCCESS) {

Review Comment:
   connection没有close时直接复用,xaended就是true了,如何再次end? @xiaoxiangyeyu0 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] bugfix: modify XA mode pre commit transaction from commit phase to before close phase [incubator-seata]

Posted by "xiaoxiangyeyu0 (via GitHub)" <gi...@apache.org>.
xiaoxiangyeyu0 commented on code in PR #7102:
URL: https://github.com/apache/incubator-seata/pull/7102#discussion_r1919657459


##########
rm-datasource/src/main/java/org/apache/seata/rm/datasource/xa/ConnectionProxyXA.java:
##########
@@ -117,6 +117,10 @@ private void xaEnd(XAXid xaXid, int flags) throws XAException {
         if (!xaEnded) {
             xaResource.end(xaXid, flags);
             xaEnded = true;
+        } else {
+            if (flags == XAResource.TMSUCCESS) {

Review Comment:
   传入的flags值为XAResource.TMSUCCESS,走else的分支会执行end



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] bugfix: modify XA mode pre commit transaction from commit phase to before close phase [incubator-seata]

Posted by "xiaoxiangyeyu0 (via GitHub)" <gi...@apache.org>.
xiaoxiangyeyu0 commented on code in PR #7102:
URL: https://github.com/apache/incubator-seata/pull/7102#discussion_r1912920037


##########
rm-datasource/src/main/java/org/apache/seata/rm/datasource/xa/ConnectionProxyXA.java:
##########
@@ -223,34 +233,12 @@ public synchronized void commit() throws SQLException {
             throw new SQLException("should NOT commit on an inactive session", SQLSTATE_XA_NOT_END);
         }
         try {
-            // XA End: Success
-            try {
-                end(XAResource.TMSUCCESS);
-            } catch (SQLException sqle) {
-                // Rollback immediately before the XA Branch Context is deleted.
-                String xaBranchXid = this.xaBranchXid.toString();
-                rollback();
-                throw new SQLException("Branch " + xaBranchXid + " was rollbacked on committing since " + sqle.getMessage(), SQLSTATE_XA_NOT_END, sqle);
-            }
-            long now = System.currentTimeMillis();
-            checkTimeout(now);
-            setPrepareTime(now);
-            int prepare = xaResource.prepare(xaBranchXid);
-            // Based on the four databases: MySQL (8), Oracle (12c), Postgres (16), and MSSQL Server (2022),
-            // only Oracle has read-only optimization; the others do not provide read-only feedback.
-            // Therefore, the database type check can be eliminated here.
-            if (prepare == XAResource.XA_RDONLY) {
-                // Branch Report to TC: RDONLY
-                reportStatusToTC(BranchStatus.PhaseOne_RDONLY);
-            }
-        } catch (XAException xe) {
-            // Branch Report to TC: Failed
-            reportStatusToTC(BranchStatus.PhaseOne_Failed);
-            throw new SQLException(
-                "Failed to end(TMSUCCESS)/prepare xa branch on " + xid + "-" + xaBranchXid.getBranchId() + " since " + xe
-                    .getMessage(), xe);
+            xaEnd(xaBranchXid, XAResource.TMSUCCESS);

Review Comment:
   已调整为end方法



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] bugfix: modify XA mode pre commit transaction from commit phase to before close phase [incubator-seata]

Posted by "xiaoxiangyeyu0 (via GitHub)" <gi...@apache.org>.
xiaoxiangyeyu0 commented on code in PR #7102:
URL: https://github.com/apache/incubator-seata/pull/7102#discussion_r1912899792


##########
rm-datasource/src/main/java/org/apache/seata/rm/datasource/xa/ConnectionProxyXA.java:
##########
@@ -324,13 +308,41 @@ private void checkTimeout(Long now) throws XAException {
 
     @Override
     public synchronized void close() throws SQLException {
-        rollBacked = false;
-        if (isHeld() && shouldBeHeld()) {
-            // if kept by a keeper, just hold the connection.
-            return;
+        try {
+            if (xaEnded) {
+                termination();

Review Comment:
   已调整commit从调用xaEnd改为end方法,这里已去掉



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] bugfix: modify XA mode pre commit transaction from commit phase to before close phase [incubator-seata]

Posted by "funky-eyes (via GitHub)" <gi...@apache.org>.
funky-eyes commented on code in PR #7102:
URL: https://github.com/apache/incubator-seata/pull/7102#discussion_r1916822710


##########
rm-datasource/src/main/java/org/apache/seata/rm/datasource/xa/ConnectionProxyXA.java:
##########
@@ -117,6 +117,10 @@ private void xaEnd(XAXid xaXid, int flags) throws XAException {
         if (!xaEnded) {
             xaResource.end(xaXid, flags);
             xaEnded = true;
+        } else {
+            if (flags == XAResource.TMSUCCESS) {

Review Comment:
   @xiaoxiangyeyu0 我看到只在close的时候至为false



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] Fix bug in https://github.com/apache/incubator-seata/issues/7100 [incubator-seata]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #7102:
URL: https://github.com/apache/incubator-seata/pull/7102#issuecomment-2585535141

   ## [Codecov](https://app.codecov.io/gh/apache/incubator-seata/pull/7102?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   Attention: Patch coverage is `28.57143%` with `30 lines` in your changes missing coverage. Please review.
   > Project coverage is 52.65%. Comparing base [(`2438d77`)](https://app.codecov.io/gh/apache/incubator-seata/commit/2438d77257be09e0d20e25d19348c3afa890854b?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) to head [(`acb9220`)](https://app.codecov.io/gh/apache/incubator-seata/commit/acb9220b737e671a7ed2593c713d9837a913b1f6?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/incubator-seata/pull/7102?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
   |---|---|---|
   | [...ache/seata/rm/datasource/xa/ConnectionProxyXA.java](https://app.codecov.io/gh/apache/incubator-seata/pull/7102?src=pr&el=tree&filepath=rm-datasource%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fseata%2Frm%2Fdatasource%2Fxa%2FConnectionProxyXA.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cm0tZGF0YXNvdXJjZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2VhdGEvcm0vZGF0YXNvdXJjZS94YS9Db25uZWN0aW9uUHJveHlYQS5qYXZh) | 28.57% | [25 Missing and 5 partials :warning: ](https://app.codecov.io/gh/apache/incubator-seata/pull/7102?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   
   <details><summary>Additional details and impacted files</summary>
   
   
   [![Impacted file tree graph](https://app.codecov.io/gh/apache/incubator-seata/pull/7102/graphs/tree.svg?width=650&height=150&src=pr&token=tbmHt2ZfxO&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)](https://app.codecov.io/gh/apache/incubator-seata/pull/7102?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   ```diff
   @@             Coverage Diff              @@
   ##                2.x    #7102      +/-   ##
   ============================================
   - Coverage     52.67%   52.65%   -0.03%     
   + Complexity     6697     6696       -1     
   ============================================
     Files          1134     1134              
     Lines         40310    40316       +6     
     Branches       4722     4724       +2     
   ============================================
   - Hits          21234    21228       -6     
   - Misses        17043    17056      +13     
   + Partials       2033     2032       -1     
   ```
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/incubator-seata/pull/7102?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [...ache/seata/rm/datasource/xa/ConnectionProxyXA.java](https://app.codecov.io/gh/apache/incubator-seata/pull/7102?src=pr&el=tree&filepath=rm-datasource%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fseata%2Frm%2Fdatasource%2Fxa%2FConnectionProxyXA.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cm0tZGF0YXNvdXJjZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2VhdGEvcm0vZGF0YXNvdXJjZS94YS9Db25uZWN0aW9uUHJveHlYQS5qYXZh) | `48.87% <28.57%> (-8.11%)` | :arrow_down: |
   
   ... and [4 files with indirect coverage changes](https://app.codecov.io/gh/apache/incubator-seata/pull/7102/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] bugfix: modify XA mode pre commit transaction from commit phase to before close phase [incubator-seata]

Posted by "funky-eyes (via GitHub)" <gi...@apache.org>.
funky-eyes merged PR #7102:
URL: https://github.com/apache/incubator-seata/pull/7102


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] bugfix: modify XA mode pre commit transaction from commit phase to before close phase [incubator-seata]

Posted by "xiaoxiangyeyu0 (via GitHub)" <gi...@apache.org>.
xiaoxiangyeyu0 commented on code in PR #7102:
URL: https://github.com/apache/incubator-seata/pull/7102#discussion_r1912892414


##########
rm-datasource/src/main/java/org/apache/seata/rm/datasource/xa/ConnectionProxyXA.java:
##########
@@ -324,13 +308,41 @@ private void checkTimeout(Long now) throws XAException {
 
     @Override
     public synchronized void close() throws SQLException {
-        rollBacked = false;
-        if (isHeld() && shouldBeHeld()) {
-            // if kept by a keeper, just hold the connection.
-            return;
+        try {
+            if (xaEnded) {
+                termination();
+                long now = System.currentTimeMillis();
+                checkTimeout(now);
+                setPrepareTime(now);
+                int prepare = xaResource.prepare(xaBranchXid);

Review Comment:
   rollback方法的finally会调用cleanXABranchContext,这里会把xaEnded置为false



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] bugfix: modify XA mode pre commit transaction from commit phase to before close phase [incubator-seata]

Posted by "xiaoxiangyeyu0 (via GitHub)" <gi...@apache.org>.
xiaoxiangyeyu0 commented on code in PR #7102:
URL: https://github.com/apache/incubator-seata/pull/7102#discussion_r1912906186


##########
rm-datasource/src/main/java/org/apache/seata/rm/datasource/xa/ConnectionProxyXA.java:
##########
@@ -223,34 +233,12 @@ public synchronized void commit() throws SQLException {
             throw new SQLException("should NOT commit on an inactive session", SQLSTATE_XA_NOT_END);
         }
         try {
-            // XA End: Success
-            try {
-                end(XAResource.TMSUCCESS);
-            } catch (SQLException sqle) {
-                // Rollback immediately before the XA Branch Context is deleted.
-                String xaBranchXid = this.xaBranchXid.toString();
-                rollback();
-                throw new SQLException("Branch " + xaBranchXid + " was rollbacked on committing since " + sqle.getMessage(), SQLSTATE_XA_NOT_END, sqle);
-            }
-            long now = System.currentTimeMillis();
-            checkTimeout(now);
-            setPrepareTime(now);
-            int prepare = xaResource.prepare(xaBranchXid);
-            // Based on the four databases: MySQL (8), Oracle (12c), Postgres (16), and MSSQL Server (2022),
-            // only Oracle has read-only optimization; the others do not provide read-only feedback.
-            // Therefore, the database type check can be eliminated here.
-            if (prepare == XAResource.XA_RDONLY) {
-                // Branch Report to TC: RDONLY
-                reportStatusToTC(BranchStatus.PhaseOne_RDONLY);
-            }
-        } catch (XAException xe) {
-            // Branch Report to TC: Failed
-            reportStatusToTC(BranchStatus.PhaseOne_Failed);
-            throw new SQLException(
-                "Failed to end(TMSUCCESS)/prepare xa branch on " + xid + "-" + xaBranchXid.getBranchId() + " since " + xe
-                    .getMessage(), xe);
+            xaEnd(xaBranchXid, XAResource.TMSUCCESS);
+        } catch (XAException e) {
+            throw new SQLException("Failed to end(TMSUCCESS) xa branch on " + xid + "-" + xaBranchXid.getBranchId()
+                    + " since " + e.getMessage(), e);
         } finally {
-            cleanXABranchContext();
+            xaActive = false;

Review Comment:
   这里置为false是因为,自动提交事务第二次调用setAutoCommit时,if (xaActive)这里会调用commit方法,currentAutoCommitStatus在第一次被置为false,进入会继续执行end方法就会报错。
   现在commit方法的xaActive = false;逻辑已去掉,setAutoCommit新加了一层判断 if (xaActive && !xaEnded)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org