Skip to content

fix(storage): reclaim when a flusher waits for a clean block - #1374

Open
tonyalaribe wants to merge 1 commit into
foyer-rs:mainfrom
tonyalaribe:fix/reclaim-when-no-clean-block
Open

tonyalaribe wants to merge 1 commit into
foyer-rs:mainfrom
tonyalaribe:fix/reclaim-when-no-clean-block

Conversation

@tonyalaribe

Copy link
Copy Markdown

Start a reclaim when get_clean_block has to park a waiter, and once at the end of BlockManager::init. Previously reclaim ran only after taking a clean block or finishing a write or reclaim. A device recovered with 0 clean blocks therefore parked every flusher forever and never wrote again. on_reclaim_finish already hands the reclaimed block to a waiting flusher, and reclaim_if_needed still respects clean_block_threshold and reclaim concurrency.

Add test_store_write_after_recovery_without_clean_block. It overwrites every block file with a block that holds data, reopens the store, enqueues an entry, and bounds wait() with a 10 s timeout. This needs tokio's time feature in dev-dependencies.

Validation:

  • The new test fails with Elapsed without the fix and passes with it.
  • cargo test -p foyer-storage: 29 lib tests passed.
  • cargo fmt clean.

Fixes #1373.

A block device recovered with no clean block never wrote again: reclaim
only runs after taking a clean block or finishing a write or reclaim, so
get_clean_block parked every flusher forever. Start a reclaim when a
waiter registers, and once after recovery.

@MrCroxx MrCroxx left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. Thank you, Anthony.

BTW, would you mind follow #1373 to pass the DCO test. 🙏 Is not necessary, but recommended.

@MrCroxx MrCroxx added the bug Something isn't working label Oct 12, 2026
@MrCroxx MrCroxx added this to the v0.23 milestone Oct 12, 2026
@codecov

codecov Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
foyer-storage/src/engine/block/engine.rs 93.75% <100.00%> (+0.22%) ⬆️
foyer-storage/src/engine/block/manager.rs 98.20% <100.00%> (+0.01%) ⬆️

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

bug: block engine never writes again after recovering with 0 clean blocks

2 participants