Skip to content

fix(mcp): serialize ADR access across processes#892

Open
SS-42 wants to merge 1 commit into
DeusData:mainfrom
SS-42:fix/adr-cross-process-lock
Open

fix(mcp): serialize ADR access across processes#892
SS-42 wants to merge 1 commit into
DeusData:mainfrom
SS-42:fix/adr-cross-process-lock

Conversation

@SS-42

@SS-42 SS-42 commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add a cache-local POSIX advisory lock for pipeline rebuilds shared by independent MCP/CLI processes using the same CBM_CACHE_DIR
  • make blocking lock acquisition report backend failures instead of leaving callers waiting indefinitely
  • serialize manage_adr reads, writes, and legacy migration with rebuilds, and reopen stale file-backed stores before ADR access

Environment observed

  • macOS arm64
  • multiple independent MCP/CLI processes using one shared CBM_CACHE_DIR

Repro covered by tests

  • one process holding the pipeline lock makes another process try_lock report busy
  • a blocking lock in another process waits until the first process releases it
  • lock backend open failures release the process-local lock
  • manage_adr(update) cannot write while another process owns the rebuild lock

Verification

  • git diff --check
  • ./build/c/test-runner pipeline (218 passed)
  • ./build/c/test-runner mcp (141 passed)
  • scripts/build.sh --version 0.8.1-adrfix.20260705d CC=clang CXX=clang++

@SS-42 SS-42 force-pushed the fix/adr-cross-process-lock branch 3 times, most recently from 5ae3a19 to 42b1878 Compare July 5, 2026 19:03
Use a cache-local advisory lock so independent MCP and CLI processes sharing CBM_CACHE_DIR cannot rebuild the same project DB concurrently.

Serialize manage_adr reads and writes with rebuilds, reopen stale file-backed stores before ADR access, and cover the cross-process lock behavior with fork-based regression tests.

Signed-off-by: SS-42 <noreply@incogni.to>
@SS-42 SS-42 force-pushed the fix/adr-cross-process-lock branch from 42b1878 to c52e266 Compare July 5, 2026 23:20
@SS-42 SS-42 marked this pull request as ready for review July 6, 2026 00:47
@SS-42 SS-42 requested a review from DeusData as a code owner July 6, 2026 00:47
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.

1 participant