Skip to content

bug(semantic_extract): cache race — concurrent writers share same .tmp path #289

@egouilliard-leyton

Description

@egouilliard-leyton

Context

Discovered during review of epic #271 (graphify parity closeout).

Description

In codegraph/semantic_extract.py:96-103, SemanticCache.put() writes to {key}.tmp then atomically replaces the target. But if two processes index concurrently with the same cache dir, they both write to the same .tmp path, causing data corruption or an OSError on Windows.

Suggested approach

Use tempfile.NamedTemporaryFile(dir=cache_dir, delete=False) instead of a deterministic .tmp suffix, then os.replace() the tempfile into place. This is the standard atomic-write-to-unique-tmp pattern.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions