fix(engine): 种子意图任务误触发首轮 planner(Frontier 只数 open 与 worker claim 竞态)
Run 里「跳过首轮」依赖种子意图让 frontier 非空,但 Frontier 只数 state='open', 而 Run 先起 worker、后查 frontier——worker 抢先 claim 种子意图(open→running)后, Frontier(open) 变空 → 误发 t.Notify() → 首轮 planner 立刻触发(日志 "edge 触发")。 改为 HasActiveIntent(open 或 running):种子无论 open 还是已被 claim 成 running 都算 「有活干」,一律跳过首轮。首轮延后到种子 worker 收工(NotifyDone)/出 finding/心跳。 顺带修好重启恢复时只剩 running 意图也会误 kick 的情况。
This commit is contained in:
1 parent
47ba58bda6
commit
4835cb57bd
2 files changed
+18
-4
No files matched your search
@@ -381,6 +381,18 @@ ORDER BY priority DESC, id ASC LIMIT $2`, s.expID, limit)
|
||||
return scanNodes(rows)
|
||||
}
|
||||
|
||||
// HasActiveIntent reports whether this exploration has any intent still in play
|
||||
// (state open OR running). Used to decide whether to kick the FIRST planner round:
|
||||
// a seeded task's intent may already have been claimed (open→running) by a worker
|
||||
// before the check, so counting only 'open' (Frontier) races with worker claim and
|
||||
// wrongly kicks a redundant first round. Counting open+running is race-proof.
|
||||
func (s *ExplorationStore) HasActiveIntent() (bool, error) {
|
||||
var exists bool
|
||||
err := s.db.QueryRow(`SELECT EXISTS(SELECT 1 FROM exploration_nodes
|
||||
WHERE exploration_id=$1 AND kind='intent' AND state IN ('open','running'))`, s.expID).Scan(&exists)
|
||||
return exists, err
|
||||
}
|
||||
|
||||
// ClaimIntent atomically moves an open intent to running. Returns true if claimed.
|
||||
func (s *ExplorationStore) ClaimIntent(id int64, owner string) (bool, error) {
|
||||
res, err := s.db.Exec(`UPDATE exploration_nodes SET state='running', owner=$1
|
||||
|
||||
Reference in new issue
Block a user