fix: cover archived stuck documents in scanner
This commit is contained in:
@@ -703,10 +703,9 @@ async def _scan_and_fail_stuck_documents(*, timeout_minutes: int) -> dict[str, A
|
||||
END
|
||||
))::bigint AS idle_seconds
|
||||
FROM leaudit_documents d
|
||||
JOIN leaudit_audit_runs ar
|
||||
LEFT JOIN leaudit_audit_runs ar
|
||||
ON ar.id = d.current_run_id
|
||||
WHERE d.deleted_at IS NULL
|
||||
AND d.is_latest_version = true
|
||||
AND (
|
||||
LOWER(COALESCE(ar.status, '')) IN ('pending', 'queued', 'running', 'retrying')
|
||||
OR LOWER(COALESCE(d.processing_status, '')) IN ('waiting', 'queued', 'running', 'processing')
|
||||
@@ -741,7 +740,7 @@ async def _scan_and_fail_stuck_documents(*, timeout_minutes: int) -> dict[str, A
|
||||
|
||||
for row in timed_out_rows:
|
||||
document_id = int(row["document_id"])
|
||||
run_id = int(row["run_id"])
|
||||
run_id = int(row["run_id"]) if row.get("run_id") is not None else None
|
||||
idle_seconds = int(row.get("idle_seconds") or 0)
|
||||
run_phase = row.get("phase")
|
||||
run_status = row.get("run_status")
|
||||
@@ -757,6 +756,7 @@ async def _scan_and_fail_stuck_documents(*, timeout_minutes: int) -> dict[str, A
|
||||
|
||||
try:
|
||||
await _update_status_safe(document_id, "failed")
|
||||
if run_id is not None:
|
||||
await storage.fail_run(
|
||||
document_id,
|
||||
run_id=run_id,
|
||||
|
||||
Reference in New Issue
Block a user