YongGoose commented on code in PR #7133: URL: https://github.com/apache/incubator-seata/pull/7133#discussion_r1955426063
########## 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 is set when the transaction is created. When the Seata server's business thread changes the transaction status from "Rollbacking" to "Rollbacked," your timeToDeadSession method directly subtracts the current timestamp from beginTime, which will inevitably result in a negative value. As a result, the business thread will delete the transaction, and your scheduled task will also delete the transaction, leading to a concurrency issue and thread safety problem. I believe that beginTime should be increased by the corresponding transaction timeout, plus an additional buffer time to ensure thread safety. Since our comments were written at the same time, I didn’t see yours when I was writing mine. 😅 Thank you for the additional explanation! In that case, I will adjust the execution interval for sessions in the `end state` to be shorter using an `if` condition. -- 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