fix(mcp): serialize ADR access across processes#892
Conversation
42b1878 to
c52e266
Compare
c52e266 to
ba39ffd
Compare
|
Thanks for the process-serialization work. Triage: high-priority stability bug. Review will focus on lock scope and failure behavior: same-project serialization without blocking unrelated projects, no watcher/self-lock deadlocks, safe stale-store reopen behavior, and ADR migration/write ordering across independent MCP/CLI processes. |
|
Thanks — this addresses a real gap (independent MCP/CLI processes sharing one CBM_CACHE_DIR had no cross-process serialization), and the lock hygiene is right: 0600 lock files under the cache dir, FD_CLOEXEC, unlock-before-close, per-project scoping so unrelated indexes don't serialize, and project names are sanitized upstream so the lock filename is traversal-safe. The fork-based cross-process tests are a nice touch. Two changes requested before merge:
Everything else looks merge-ready: 19/19 checks green, clean mergeable state against current main (impressive, given how much |
Use project-scoped cache-local advisory locks so independent MCP and CLI processes sharing CBM_CACHE_DIR cannot rebuild the same project DB concurrently without blocking unrelated project indexes. Serialize manage_adr reads and writes with same-project rebuilds, reopen stale file-backed stores before ADR access, and avoid watcher self-locking when a supervised worker performs the reindex. Cover the cross-process lock behavior with fork-based regression tests. Signed-off-by: SS-42 <noreply@incogni.to>
ba39ffd to
0a8b63e
Compare
Summary
CBM_CACHE_DIRmanage_adrreads, writes, and legacy migration with same-project rebuilds, and reopen stale file-backed stores before ADR accessEnvironment observed
CBM_CACHE_DIRRepro covered by tests
try_lockreport busy for the same projectmanage_adr(update)cannot write while another process owns the same-project rebuild lockVerification
git diff --checkASAN_OPTIONS=detect_leaks=0 build/c/test-runner pipeline mcp(360 passed)scripts/test.sh CC=clang CXX=clang++(5920 passed, 1 skipped; watchdog regressions passed; security allow-list passed)scripts/build.sh --version 0.8.1-adrfix.20260706a CC=clang CXX=clang++