Skip to content

fix(session): orphan running sessions reaper + interrupt finish (#1251)#1254

Merged
FabioLeitao merged 2 commits into
mainfrom
fix/orphan-session-reaper-1251
Jul 15, 2026
Merged

fix(session): orphan running sessions reaper + interrupt finish (#1251)#1254
FabioLeitao merged 2 commits into
mainfrom
fix/orphan-session-reaper-1251

Conversation

@FabioLeitao

Copy link
Copy Markdown
Collaborator

Summary

  • A) CLI/API interrupt path marks sessions interrupted (engine KeyboardInterruptfinish_session; SIGTERM→KeyboardInterrupt on scan CLI; finish_session refuses to overwrite non-running).
  • B) Concurrency-safe reaper: pid + owner_hostname on open; migrate via ALTER; reap_orphaned_running_sessions() at DB init reaps dead/NULL PIDs only — never a live PID.

Test plan

  • ./scripts/check-all.sh --enforced (green)
  • Unit: null PID / dead PID reaped; live os.getpid() skipped; legacy DB without pid migrates + reaps
  • Manual: Ctrl+C mid-scan → row interrupted + finished_at set
  • Bugbot review (requested) on reaper concurrency + migration

Closes #1251

Made with Cursor

Ctrl+C/SIGTERM and dead-PID rows no longer leave scan_sessions stuck
running with finished_at NULL; live PIDs are never reaped (#1251).

Closes #1251
Reap only with WHERE status='running' so a concurrent completed finish
cannot be overwritten as interrupted (#1251 / Bugbot).
@FabioLeitao
FabioLeitao merged commit 94bbcaf into main Jul 15, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[P1][bug] Sessoes interrompidas ficam presas em status='running' com finished_at=NULL (nunca transicionam para estado terminal)

1 participant