imbajin commented on code in PR #336:
URL: 
https://github.com/apache/incubator-hugegraph-computer/pull/336#discussion_r2444649666


##########
vermeer/apps/master/bl/scheduler_bl.go:
##########
@@ -202,6 +420,7 @@ func (s *ScheduleBl) startWaitingTask(agent 
*schedules.Agent, taskInfo *structur
                }
        }()
 
+       // TODO: Is here need a lock? TOCTTOU

Review Comment:
   **潜在的并发安全问题**: 在第 423 行检查任务状态后到实际启动任务之间存在时间窗口,这是经典的 TOCTTOU 
(Time-of-check to Time-of-use) 问题。
   
   **问题**:
   - 在检查 taskInfo.State 和调用 taskStarter.StartTask() 之间,任务状态可能被其他 
goroutine 修改
   - 这可能导致任务被重复启动或状态不一致
   
   **建议**:
   1. 在 taskStarter.StartTask() 内部进行原子性的状态检查和转换
   2. 使用互斥锁保护整个检查和启动过程
   3. 使用 atomic.CompareAndSwap 来原子地检查和更新状态
   



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