YongGoose commented on code in PR #7133:
URL: https://github.com/apache/incubator-seata/pull/7133#discussion_r1957088827


##########
server/src/main/java/org/apache/seata/server/coordinator/DefaultCoordinator.java:
##########
@@ -631,6 +645,60 @@ private void committingSchedule(long delay) {
             delay, TimeUnit.MILLISECONDS);
     }
 
+    /**
+     * Handle rollbacked by scheduled.
+     */
+    protected void handleRollbackedByScheduled() {
+        SessionCondition sessionCondition = new 
SessionCondition(rollbackedStatuses);
+        sessionCondition.setLazyLoadBranch(true);
+        List<GlobalSession> rollbackedSessions =
+            
SessionHolder.getRootSessionManager().findGlobalSessions(sessionCondition);
+        if (CollectionUtils.isEmpty(rollbackedSessions)) {
+            rollbackedSchedule(RETRY_DEAD_THRESHOLD);
+            return;
+        }
+        long delay = ROLLBACKED_RETRY_PERIOD;
+        
rollbackedSessions.sort(Comparator.comparingLong(GlobalSession::getBeginTime));
+        List<GlobalSession> needDoRollbackedSessions = new ArrayList<>();
+        for (GlobalSession rollbackedSession : rollbackedSessions) {
+            long time = rollbackedSession.timeToDeadSession();
+            if (time <= 0) {
+                needDoRollbackedSessions.add(rollbackedSession);
+            } else {
+                delay = Math.max(time, ROLLBACKED_RETRY_PERIOD);
+                break;
+            }
+        }
+        long now = System.currentTimeMillis();
+        SessionHelper.forEach(needDoRollbackedSessions, rollbackedSession -> {
+            try {
+                if (isRetryTimeout(now, MAX_ROLLBACK_RETRY_TIMEOUT, 
rollbackedSession.getBeginTime())) {
+
+                    // commit retry timeout event
+                    SessionHelper.endRollbackFailed(rollbackedSession, true, 
true);
+
+                    //The function of this 'return' is 'continue'.
+                    return;
+                }
+                core.doGlobalRollback(rollbackedSession, true);

Review Comment:
   @funky-eyes 
   
   When you have time, I would appreciate it if you could review this comment 
and the issue below.
   - https://github.com/apache/incubator-seata/issues/6774



-- 
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-unsubscr...@seata.apache.org

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


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

Reply via email to