Repository navigation
fix(mcp): release an idle explicit project and its writer lock (#2087) - #2093
Closed
danusha2345 wants to merge 1 commit into
Closed
danusha2345 wants to merge 1 commit into
danusha2345 wants to merge 1 commit into
Conversation
…mchenry#2087) 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 (colbymchenry#1835). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
danusha2345
force-pushed
the
fix/2087-release-secondary-writer-lock
branch
from
September 30, 2026 18:59
a406e11 to
092d49d
Compare
Owner
|
Thank you! This landed in #2283: your commit carried onto current |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2087 (reported, with the idle-release approach, by @bompus — thanks).
When a daemon answers a
projectPathquery for another indexed project that has no owner, it opens that project in-process and takes its writer lock (#1835). 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 andcodegraph indexthere was refused until the first daemon exited.This releases a cached explicit project after it has gone unused for 10 minutes (
CODEGRAPH_PROJECT_IDLE_TIMEOUT_MS;0never releases). The release goes through the same path as LRU eviction, so an in-flight call or a still-running catch-up defers it, and it frees the SQLite handle, the watcher, the writer lock and any held daemon session. The next call reopens the project and catches it up, so #1835's "explicit projects stay synchronized while in use" is unchanged.Not taking the writer lock at all was considered and rejected: a project with no daemon of its own would then go unsynchronized while it is being queried.
Interaction with #1929 (keep active MCP project connections open): both touch the cache-trim loop in
src/mcp/tools.ts; the merge is mechanical (keep #1929's guard for projects with active calls and this idle condition), and the idle timer should skip busy projects when it picks the next one.Tests
Real temp projects and SQLite, in
__tests__/mcp-projectpath-lifecycle.test.ts:writer.pid, and the next call reopens it, catches up an edit and takes the lock again;Both fail on
mainand pass with the fix; the existing lifecycle / writer-lock suites pass. Full suite on Linux: everything passes exceptui-package.test.ts > is versioned with the engine, which fails onmaintoo (ui/package.jsonis still 1.6.0 after the 1.6.1 bump).🤖 Generated with Claude Code