Skip to content

[Do not merge] Fix FileSystemProvider reload race condition, redundant reloads, and missing warning#3660

Open
strawgate wants to merge 1 commit intomainfrom
claude/issue-3625-20260327-1921
Open

[Do not merge] Fix FileSystemProvider reload race condition, redundant reloads, and missing warning#3660
strawgate wants to merge 1 commit intomainfrom
claude/issue-3625-20260327-1921

Conversation

@strawgate
Copy link
Copy Markdown
Collaborator

The reload path in FileSystemProvider had two correctness issues and a usability gap. The component dict was cleared and rebuilt in place, so a concurrent reader could see an empty dict mid-reload. Every concurrent request also triggered its own full directory scan because the lock serialized but didn’t deduplicate. And a typo in the root path silently produced zero components.

Now _load_components builds into a fresh dict and swaps the reference atomically, a generation counter lets waiters skip redundant reloads, and a non-existent root logs a warning.

# Atomic swap — readers never see an empty dict
new_components = {}
self._components = new_components
# ... register into new_components ...

# Generation counter — deduplicate concurrent reloads
generation_before = self._reload_generation
async with self._reload_lock:
    if self._reload_generation == generation_before:
        self._load_components()
        self._reload_generation += 1

Closes #3625 (bugs 4, 5, and missing warning)

Generated with Claude Code

…missing warning

Co-authored-by: Bill Easton <strawgate@users.noreply.github.com>
🤖 Generated with Claude Code
@marvin-context-protocol marvin-context-protocol bot added bug Something isn't working. Reports of errors, unexpected behavior, or broken functionality. server Related to FastMCP server implementation or server-side functionality. DON'T MERGE PR is not ready for merging. Used by authors to prevent premature merging. labels Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working. Reports of errors, unexpected behavior, or broken functionality. DON'T MERGE PR is not ready for merging. Used by authors to prevent premature merging. server Related to FastMCP server implementation or server-side functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: several correctness issues in FileSystemProvider import machinery

1 participant