Skip to content

fix(mcp): release an idle explicit project and its writer lock (#2087) - #2283

Merged
colbymchenry merged 2 commits into
mainfrom
carry/2093-release-idle-project
Oct 2, 2026
Merged

colbymchenry merged 2 commits into
mainfrom
carry/2093-release-idle-project

Conversation

@colbymchenry

Copy link
Copy Markdown
Owner

Carries #2093 by @danusha2345 onto current main. The commit keeps its author; the only addition is a changelog credit.

Closes #2087.

What was wrong

When a session's daemon answered a codegraph_explore call with an explicit projectPath for another indexed project, it opened that project in-process and took its writer lock. The project cache had no idle release, so the daemon kept the lock for as long as it ran. That project's own daemon then couldn't become the writer, and codegraph index there was blocked. On Windows, the open handle and watcher also stopped the folder from being renamed or deleted.

Fix

  • A project opened through an explicit projectPath is released after it goes unused for CODEGRAPH_PROJECT_IDLE_TIMEOUT_MS (10 minutes by default; 0 never releases it).
  • Releasing frees the SQLite handle, the watcher and the writer lock. The next call reopens the project and catches it up.
  • One unref'd timer handles the release, and it never fires mid-call or during a catch-up still in progress.
  • The session's default project is never cached, so it is never released.

Verification

mcp-projectpath-lifecycle, concurrent-locking and root-identity: 44 tests pass on current main. They include the two new cases: an idle project releases and later retakes its writer lock, and a release waits for an active catch-up.

🤖 Generated with Claude Code

danusha2345 and others added 2 commits October 1, 2026 23:14
A daemon that answered a `projectPath` query for another indexed project
opened it in-process and, with no owner there, took its writer lock. The
project cache only evicted over its LRU bound or on shutdown, so the lock
stayed held for the daemon's whole life: the project's own daemon could not
become its writer and `codegraph index` there was refused.

Release a cached explicit project once it has gone unused for 10 minutes
(CODEGRAPH_PROJECT_IDLE_TIMEOUT_MS; 0 never releases), through the same
trim path as LRU eviction, so an active call or a running catch-up still
defers it. The next call reopens the project and catches it up (#1835).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 092d49d)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

A daemon keeps the writer lock of a project it opened for one projectPath query

1 participant