You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@seata.apache.org by "funky-eyes (via GitHub)" <gi...@apache.org> on 2025/02/13 01:33:40 UTC

Re: [PR] feature: Implement Scheduled Handling for Rollbacked and TimeoutRollbacked Transaction [incubator-seata]

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


##########
server/src/main/java/org/apache/seata/server/coordinator/DefaultCoordinator.java:
##########
@@ -189,12 +197,15 @@ public class DefaultCoordinator extends AbstractTCInboundHandler implements Tran
 
     private final GlobalStatus[] retryRollbackingStatuses = new GlobalStatus[] {
         GlobalStatus.TimeoutRollbacking,
-        GlobalStatus.TimeoutRollbackRetrying, GlobalStatus.RollbackRetrying};
+        GlobalStatus.TimeoutRollbackRetrying,
+        GlobalStatus.RollbackRetrying
+    };
 
     private final GlobalStatus[] retryCommittingStatuses = new GlobalStatus[] {GlobalStatus.CommitRetrying, GlobalStatus.Committed};
 
     private final GlobalStatus[] rollbackingStatuses = new GlobalStatus[] {GlobalStatus.Rollbacking};
     private final GlobalStatus[] committingStatuses = new GlobalStatus[] {GlobalStatus.Committing};
+    private final GlobalStatus[] rollbackedStatuses = new GlobalStatus[] {GlobalStatus.Rollbacked, GlobalStatus.TimeoutRollbacked};

Review Comment:
   Why not process transactions in other end states together?



##########
server/src/main/java/org/apache/seata/server/session/GlobalSession.java:
##########
@@ -204,9 +204,17 @@ public boolean isTimeout() {
 
     /**
      * prevent could not handle committing and rollbacking transaction
+     *
+     * If the global session's status is "Rollbacked" or "TimeoutRollbacked", it returns the negative time since the session began,
+     * indicating that the session is already dead.
+     * For other statuses, it returns the remaining time until the session reaches the retry dead threshold.
+     *
      * @return time to dead session. if not greater than 0, then deadSession
      */
     public long timeToDeadSession() {
+        if (this.status == GlobalStatus.Rollbacked || this.status == GlobalStatus.TimeoutRollbacked) {
+            return beginTime - System.currentTimeMillis();

Review Comment:
   The beginTime does not change after the creation of the global session, which will cause any global session to be added to the needDoRollbackedSessions list.



##########
server/src/main/java/org/apache/seata/server/coordinator/DefaultCoordinator.java:
##########
@@ -658,6 +724,8 @@ public void init() {
         rollbackingSchedule(0);
 
         committingSchedule(0);
+
+        rollbackedSchedule(0);

Review Comment:
   The methods `rollbackingSchedule`, `committingSchedule`, and `rollbackedSchedule` need to use the `SessionHolder.distributedLockAndExecute` method to ensure thread safety in a distributed environment.



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