Pass 3 of 3 · Deep dive of PHAROSPass 1 · OverviewPass 2 · How it works
Code Observatory / function
recover_stale
codeintel.jobs.recover_stale
PINNED SOURCE Source and edges from the index at this commit. An execution appears only where one was recorded.
PHAROS at 975a38dMIT license
Around this symbol
Search all symbolsLoading
codeintel.jobs.recover_stalebackend/app/codeintel/jobs.py, lines 211–236Open source
def recover_stale(db: Session, stale_after_seconds: int, model: JobModel = IngestionJob) -> list[uuid.UUID]: """Re-queue running jobs whose worker stopped heartbeating. Returns the ids put back in the queue (callers re-notify them). """ cutoff = utcnow() - timedelta(seconds=stale_after_seconds) stale = db.execute( select(model).where(model.status == "running", model.heartbeat_at < cutoff) ).scalars().all() requeued = [] for job in stale: if job.attempts >= job.max_attempts: job.status = "failed" job.error_kind = "worker_lost" job.error = f"worker {job.worker_id} stopped responding; attempts exhausted" job.finished_at = utcnow() else: job.status = "queued" job.error_kind = "worker_lost" job.error = f"worker {job.worker_id} stopped responding; re-queued" requeued.append(job.id) db.commit() if stale: logger.warning("Recovered %d stale %s(s); %d re-queued", len(stale), model.__tablename__[:-1], len(requeued)) return requeuedWhat the index recorded
- Signature
def recover_stale(db: Session, stale_after_seconds: int, model: JobModel) -> list[uuid.UUID]:- File
backend/app/codeintel/jobs.py- Lines
- 211–236
- Parser
- python-ast
- Git blob
54c9a5d84ee5feda5176c3e05d0aa9a7d46f6016- Call sites
- 11 named, 5 resolved, 6 left unlinked
- Outside this subset
- 8 more edges reach code outside the graph shown here
