Copilot commented on code in PR #1148:
URL: 
https://github.com/apache/incubator-seata-go/pull/1148#discussion_r3869367137


##########
pkg/datasource/sql/xa_resource_manager.go:
##########
@@ -91,15 +92,14 @@ func (xaManager *XAResourceManager) 
xaTwoPhaseTimeoutChecker() {
                                if !ok {
                                        return true
                                }
-                               if source.IsShouldBeHeld() {
-                                       return true
-                               }
-
                                source.GetKeeper().Range(func(key, value any) 
bool {
                                        connectionXA, isConnectionXA := 
value.(*XAConn)
                                        if !isConnectionXA {
                                                return true
                                        }
+                                       if connectionXA.ShouldBeHeld() {
+                                               return true
+                                       }
 
                                        if 
time.Now().Sub(connectionXA.prepareTime) > xaManager.config.TwoPhaseHoldTime {

Review Comment:
   xaTwoPhaseTimeoutChecker currently returns early when 
connectionXA.ShouldBeHeld() is true. Since keeper entries are only created for 
held branches, this prevents the timeout sweep from ever force-closing 
leaked/stuck phase-2 owner connections. Also, reading prepareTime without 
synchronization can race with phase-1 setting it (and if it’s still zero, the 
timeout computation is nonsensical). Consider snapshotting xaActive/prepareTime 
under keeperMu and only applying the timeout after the branch has actually been 
prepared.



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