Skip to content

Fix race conditions in file cache and block cache - #1077

Open
jfantinhardesty wants to merge 2 commits into
mainfrom
fix/fix-race-conditions
Open

jfantinhardesty wants to merge 2 commits into
mainfrom
fix/fix-race-conditions

Conversation

@jfantinhardesty

Copy link
Copy Markdown
Contributor

What type of Pull Request is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Describe your changes in brief

This fixes most races that can be detected using the race detector. (There are still some races that would require a fix in the upstream tlru). In the future, we could hopefully enable the race detector in our CI/CD as well. This also adds a few tests for race conditions that were found while running cloudfuse but were not in our test suite.

Checklist

  • Tested locally
  • Added new dependencies
  • Updated documentation
  • Added tests

Related Issues

  • Related Issue #
  • Closes #

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Worker shutdown can still accept lost work, and block-cache workers still race with handle-path renames.

2 open findings
What changed in this PR

Fixes concurrency issues across cache, streaming, loopback, and xload components, with race-focused tests.

Changes:

  • Synchronizes shared cache and handle state.
  • Improves worker shutdown and async-operation cleanup.
  • Adds regression tests for concurrent reads, writes, renames, expiry, and uploads.
File Description
component/​xload/​xload_test.go Reorders configuration cleanup.
component/​xload/​threadpool.go Revises worker shutdown.
component/​xload/​threadpool_test.go Removes timing-dependent assertion.
component/​xload/​stats_manager.go Synchronizes exporter shutdown.
component/​xload/​splitter_test.go Stops all test components.
component/​xload/​lister.go Localizes goroutine error state.
component/​stream/​read.go Atomically reads cached-object count.
component/​stream/​read_test.go Avoids unsafe mock comparisons.
component/​loopback/​loopback_fs.go Locks handle-path updates and reads.
component/​loopback/​loopback_fs_test.go Tests rename/read concurrency.
component/​file_cache/​lru_policy.go Protects expiry-list inspection.
component/​file_cache/​lru_policy_test.go Tests concurrent expiry updates.
component/​file_cache/​file_cache.go Synchronizes workers, handles, and scheduling.
component/​file_cache/​file_cache_test.go Adds race regression coverage.
component/​file_cache/​async.go Locks upload-window transitions.
component/​block_cache/​threadpool.go Snapshots scheduled file size.
component/​block_cache/​threadpool_test.go Uses eventual async assertions.
component/​block_cache/​block_cache.go Coordinates uploads and overwrites.
component/​block_cache/​block_cache_test.go Tests upload/write races.
component/​attr_cache/​cacheMap.go Uses copy-on-write attributes.
component/​attr_cache/​attr_cache_test.go Tests immutable cached results.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread component/block_cache/threadpool.go
Comment thread component/xload/threadpool.go

This branch was successfully deployed

1 active deployment
testing — 9ee14f89 Deployed Oct 8, 2026 by jfantinhardesty via Cleanup Test Accounts (1.27, linux) #3830
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.

2 participants