Skip to content

fix: demote stale Lock detected warnings (#321) - #358

Merged
MattGyverLee merged 1 commit into
mainfrom
fix/321-lock-warning-spam
Oct 2, 2026
Merged

MattGyverLee merged 1 commit into
mainfrom
fix/321-lock-warning-spam

Conversation

@MattGyverLee

Copy link
Copy Markdown
Owner

Demotes the 'Lock detected' WARNING spam from sweep_stale_locks().

Problem: every .fwdata.lock finding was logged at WARNING on every sweep (server startup + each flextools_health call), and server.py re-logged each finding into operations.log -- ~200 WARNING lines for stale locks on unrelated projects (Esperanto, Malay Parsing, Target; stale PIDs) over five days, drowning real warnings in log triage.

Fix:

  • _describe_lock() now returns (message, holder_alive); holder counts as alive only when the lock's claimed PID is confirmed running.
  • sweep_stale_locks(active_project=None) logs at WARNING only when the lock is on the active session project AND held by another live process. Everything else (stale/acquirable locks, unknown holders, live holders on unrelated projects) is demoted to INFO, emitted at most once per (project, lock state) per server process via a module-level dedup set.
  • All diagnostic detail (age, holder description) is preserved in the demoted messages; the returned warning strings (flextools_health response) are unchanged.
  • flextools_health passes the session project through; the startup re-log loop in server.py that re-emitted every finding as a WARNING into operations.log is removed (the sweep logs each finding itself at the right level).

Tests: new TestSweepStaleLocksLogPolicy class (6 tests: stale->INFO once, live-on-active->WARNING, live-on-other->INFO once, unknown-holder->INFO once, stale-then-live re-logs under new state); updated test_sweep_logs_warning to the new policy. 43 passed in the lock-sweep suites, 21 passed in health/diagnosis suites, ruff check clean.

Closes #321

…roject (#321)

sweep_stale_locks() logged every .fwdata.lock finding at WARNING on every
sweep (server startup + each flextools_health call), and server.py re-logged
each one into operations.log -- ~200 WARNING lines for stale locks on
unrelated projects over five days, drowning real warnings in log triage.

_describe_lock() now returns (message, holder_alive); the sweep logs at
WARNING only when the lock is on the active session project AND held by
another live process. Everything else (stale/acquirable locks, unknown
holders, live holders on unrelated projects) is demoted to INFO, emitted at
most once per (project, lock state) per server process via a module-level
dedup set. All diagnostic detail (age, holder description) is preserved in
the demoted messages, and the returned warning strings (health response) are
unchanged. flextools_health passes the session's project through; the
startup re-log loop that re-emitted every finding as a WARNING is removed.
@MattGyverLee
MattGyverLee force-pushed the fix/321-lock-warning-spam branch from 1fc9778 to b2f83dc Compare October 2, 2026 18:32
@MattGyverLee
MattGyverLee merged commit 8a1dc8c into main Oct 2, 2026
2 checks passed
@MattGyverLee
MattGyverLee deleted the fix/321-lock-warning-spam branch October 2, 2026 18:40
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.

Stale "Lock detected" WARNING spam (~200 lines 09-26..30) for unrelated projects; demote to INFO, once per project

1 participant