refactor(mcp): async snapshot lock and workspace-scoped state#274
refactor(mcp): async snapshot lock and workspace-scoped state#274defin85 wants to merge 2 commits intozilliztech:masterfrom
Conversation
|
Heads-up for reviewers: this PR contains intentional breaking changes. Why this changeThis refactor addresses high CPU usage and lock contention in MCP snapshot persistence:
Breaking changes
Compatibility / migration
Main touched areas
Validation performed
Review focus is especially welcome on:
|
|
Hi @defin85, thanks for this thorough refactoring work — the async lock with jitter, coalesced saves, and workspace-scoped snapshot are all solid improvements. We've been tackling some related snapshot consistency issues recently (PR #283, v0.1.6), specifically around the read-merge-write pattern re-adding removed entries and the lack of VectorDB fallback when the snapshot loses track. Your workspace-scoped approach would actually complement those fixes nicely by reducing cross-session contention at the source. A few thoughts:
We'll review this more carefully when we have bandwidth for the larger refactor. Thanks for the contribution — really appreciate the detailed PR description and the thought put into the design! 🙏 |
Supersedes #272 to align with branch naming convention in
CONTRIBUTING.md(feature/...).Problem
Snapshot persistence used sync busy-wait lock backoff, causing high CPU under lock contention. Snapshot state was global, so multiple workspaces/sessions contended on one lock file.
Changes
process.cwd()).Breaking Changes
SnapshotManager.saveCodebaseSnapshot()is now async and must be awaited.Validation
packages/mcp/node_modules/.bin/tsc -p packages/mcp/tsconfig.json --noEmitpnpm --filter @zilliz/claude-context-mcp buildbash scripts/build-local-mcp.shpnpm buildAdditional Fixes (this update)
indexingsnapshot entries so they do not block futureindex_codebaserunsforce=truereindex after MCP restart by checking in-process indexing statereindexByChangeupdates soget_indexing_statusshows currentLast updatedVerification for additional fixes
pnpm --filter @zilliz/claude-context-mcp typecheckpnpm --filter @zilliz/claude-context-mcp buildindexingno longer blocks force reindex