Skip to content

Conversation

@Gosorasora
Copy link

Summary
Fixes race condition when multiple processes access the same cache file concurrently.

Related issue: wasmCloud/wasmCloud#4842

Problem
When two processes write to the same cache file simultaneously, one may read
an incomplete file, causing "unexpected end-of-file" errors.

Solution
Use atomic writes by writing to a temporary file first, then renaming it to
the final path. The rename operation is atomic on most filesystems.

Changes

  • Modified put_data in FileCache to write to temp file first
  • Added atomic rename after write completes

@Gosorasora Gosorasora force-pushed the fix/atomic-cache-write branch from 45ef6d8 to d54c997 Compare December 14, 2025 13:32
@Gosorasora Gosorasora closed this by deleting the head repository Dec 16, 2025
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