funky-eyes commented on code in PR #7997:
URL: https://github.com/apache/incubator-seata/pull/7997#discussion_r2844114383


##########
rm-datasource/src/main/java/org/apache/seata/rm/datasource/xa/ConnectionProxyXA.java:
##########
@@ -348,9 +348,13 @@ public void close() throws SQLException {
                         reportStatusToTC(BranchStatus.PhaseOne_RDONLY);
                     }
                 }
+            } catch (SQLException xe) {
+                // Branch Report to TC: Exception
+                reportStatusToTC(BranchStatus.PhaseOne_PrepareFailed);
+                throw xe;
             } catch (XAException xe) {
-                // Branch Report to TC: Failed
-                reportStatusToTC(BranchStatus.PhaseOne_Failed);
+                // Branch Report to TC: Exception
+                reportStatusToTC(BranchStatus.PhaseOne_PrepareFailed);

Review Comment:
   When the database is MariaDB or MySQL 8.0.29 (or earlier), if an END is 
executed and then an exception occurs during PREPARE, with the changes 
introduced by this PR: after the TM makes the two-phase commit decision, the 
server will directly remove this branch. However, the client may continue to 
hold onto that connection. In this case, will the resources held by the client 
connection be properly released?



##########
common/src/main/java/org/apache/seata/core/model/GlobalStatus.java:
##########
@@ -235,4 +235,17 @@ public static boolean isTwoPhaseHeuristic(GlobalStatus 
status) {
         }
         return false;
     }
+
+    /**
+     * Is one phase prepare failed boolean.
+     *
+     * @param status the status
+     * @return the boolean
+     */
+    public static boolean isOnePhasePrepareFailed(GlobalStatus status) {
+        if (status == GlobalStatus.RollbackRetrying) {

Review Comment:
   Why is a phase‑one failure determined by the global status rather than the 
branch status, and why is the check limited to whether the status is 
"RollbackRetrying"?



##########
server/src/main/java/org/apache/seata/server/coordinator/DefaultCore.java:
##########
@@ -433,7 +433,7 @@ public boolean doGlobalRollback(GlobalSession 
globalSession, boolean retrying) t
                     branchSessions,
                     branchSession -> {
                         BranchStatus currentBranchStatus = 
branchSession.getStatus();
-                        if (currentBranchStatus == 
BranchStatus.PhaseOne_Failed) {
+                        if (currentBranchStatus == 
BranchStatus.PhaseOne_Failed || currentBranchStatus == 
BranchStatus.PhaseOne_PrepareFailed) {

Review Comment:
   ditto



##########
server/src/main/java/org/apache/seata/server/coordinator/DefaultCore.java:
##########
@@ -299,7 +299,7 @@ public boolean doGlobalCommit(GlobalSession globalSession, 
boolean retrying) thr
                         }
 
                         BranchStatus currentStatus = branchSession.getStatus();
-                        if (currentStatus == BranchStatus.PhaseOne_Failed) {
+                        if (currentStatus == BranchStatus.PhaseOne_Failed || 
currentStatus == BranchStatus.PhaseOne_PrepareFailed) {

Review Comment:
   ditto



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to