-
-
Notifications
You must be signed in to change notification settings - Fork 80.7k
MCP server processes leaked across sessions — stale PID holds file lock on next reconnect #92569
Copy link
Copy link
Closed
Labels
P1High-priority user-facing bug, regression, or broken workflow.High-priority user-facing bug, regression, or broken workflow.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.ClawSweeper found an open linked pull request for this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:crash-loopCrash, hang, restart loop, or process-level availability failure.Crash, hang, restart loop, or process-level availability failure.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.
Description
Metadata
Metadata
Assignees
Labels
P1High-priority user-facing bug, regression, or broken workflow.High-priority user-facing bug, regression, or broken workflow.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.ClawSweeper found an open linked pull request for this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:crash-loopCrash, hang, restart loop, or process-level availability failure.Crash, hang, restart loop, or process-level availability failure.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.
Type
Fields
Priority
None yet
Summary
When a new session starts, the gateway spawns fresh MCP server processes but does not reap the previous session's processes. For MCP servers that use exclusive file-locking (embedded databases, SQLite, etc.), this causes the new session's MCP tool calls to fail with lock contention.
Observed behavior
Each session spawns a complete new set of MCP server processes:
For an MCP server using an embedded database with file-level locking (LadybugDB), the stale process from Session 1 holds an exclusive write lock (fcntl/F_WRLCK) on the .lbdb file. Session 2's process cannot open the database and throws lock errors.
When tool calls fail repeatedly, the gateway's MCP subsystem enters a paused/backoff state that escalates with each retry — self-deepening rather than failing fast.
Expected behavior
The gateway should either:
Workaround
Added stale-PID self-healing in the MCP server init: on lock contention, scan /proc for sibling processes with the same module path, SIGTERM them, then retry. Functional but the MCP server shouldn't manage its own lifecycle.
Environment