fix: clear stuck claimed_by tasks
This commit is contained in:
parent
e852a405f1
commit
3573684f09
26
wwwroot/api/fix_stuck.dspy
Normal file
26
wwwroot/api/fix_stuck.dspy
Normal file
@ -0,0 +1,26 @@
|
||||
# fix_stuck.dspy - 清除卡住任务的 claimed_by
|
||||
|
||||
dbname = get_module_dbname('pipeline-sdlc')
|
||||
async with DBPools().sqlorContext(dbname) as sor:
|
||||
# 清除 submitted 状态但有 claimed_by 的僵尸任务
|
||||
result = await sor.sqlExe(
|
||||
"UPDATE pipeline_tasks SET claimed_by=NULL WHERE state='submitted' AND claimed_by IS NOT NULL",
|
||||
{})
|
||||
# 同时清除 review 状态但有 claimed_by 的(超时未处理的)
|
||||
result2 = await sor.sqlExe(
|
||||
"UPDATE pipeline_tasks SET claimed_by=NULL WHERE state='review' AND claimed_by IS NOT NULL",
|
||||
{})
|
||||
|
||||
# 查看还有多少卡住的
|
||||
stuck = await sor.sqlExe(
|
||||
"SELECT id, title, role, state, claimed_by FROM pipeline_tasks WHERE claimed_by IS NOT NULL",
|
||||
{})
|
||||
|
||||
result = {
|
||||
"cleared_submitted": "done",
|
||||
"cleared_review": "done",
|
||||
"remaining_stuck": [{"id": getattr(t,'id','')[:12], "state": getattr(t,'state',''),
|
||||
"claimed_by": getattr(t,'claimed_by','')[:8]} for t in (stuck or [])]
|
||||
}
|
||||
|
||||
return json.dumps(result, ensure_ascii=False)
|
||||
Loading…
x
Reference in New Issue
Block a user