Repository navigation
fix(daemon): deterministic flush primitive for event log (#146) - #162
Merged
Merged
Conversation
Tighten the event_log test harness to expose the race in flush_logger(). Adds test_flush_is_deterministic_no_sleep_required and rewires the shared flush_logger helper to delegate to EventLogger::flush() — which does not exist yet. This produces a compile error until the GREEN commit lands the deterministic sync primitive. Refs #146. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Add `EventLogger::flush()` and replace the test-only 200ms sleep with a real cross-thread sync primitive. A new `LogMessage::Flush` sentinel carries a `std::sync::mpsc::SyncSender<()>`; the worker drains it after all earlier `Write` messages (channels are FIFO) and signals back. The caller blocks on the ack, so by the time `flush()` returns the on-disk state — including any rotation triggered by the queued writes — is fully committed. This eliminates the slow-CI race where the worker was still mid-rotation when the blind 200ms sleep elapsed and `daemon.log` had been renamed but not yet recreated, causing `test_rotation_triggers_at_threshold` to flake on Linux runners. The shared `flush_logger` test helper now delegates to `EventLogger:: flush()`. No public API beyond the new method; noop loggers short-circuit without blocking. Closes #146. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
2 tasks
zackees
added a commit
that referenced
this pull request
May 11, 2026
Patch bump covering everything merged since v1.4.0: - fix(daemon,ci): tolerate unknown sessions and stop killing soldr's daemon (#168, closes #166 + #167) - feat(cli): expose session_end_idempotent for all daemon callers (#163) - fix(daemon): deterministic flush primitive for event log (#162) - feat(cli,daemon): relocate daemon exe to global runtime-binaries dir (#158) - fix(depgraph): normalize workspace-path inputs out of rustc cache key (#160) - perf(ci): trim platform Test, drop --all-targets from Check, split Test/Check jobs (#161, #164, #165) - chore(ci): drop invalid target-cache-paths from build-target action (#157) Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces the 200 ms blind
thread::sleepinflush_loggerwith a real cross-thread sync primitive onEventLogger. Fixes the slow-CI race inevent_log::tests::test_rotation_triggers_at_thresholdwhere the background writer was still mid-rotation when the sleep elapsed, leavingdaemon.logrenamed but not yet recreated.EventLogger::flush()(public).LogMessage::Flush(std::sync::mpsc::SyncSender<()>)sentinel. The worker drains it after all earlierWritemessages (channels are FIFO) and signals back; the caller blocks on the ack. On-disk state — including rotation triggered by queued writes — is fully committed by the timeflush()returns.test_flush_is_deterministic_no_sleep_requiredasserts the file is on disk immediately afterflush()returns (no polling, no tolerance).flush_loggertest helper now delegates toEventLogger::flush()— no other call sites need to change.TDD log
1d45b1c): rewiresflush_loggerto callEventLogger::flush(), which does not exist yet → compile error.7696fde): implements the sync primitive; all 11event_logtests + all 148 daemon lib tests pass.Test plan
soldr cargo test -p zccache-daemon event_logsoldr cargo test -p zccache-daemon --lib(148 passed)soldr cargo check --workspace --all-targetssoldr cargo clippy --workspace --all-targets -- -D warningssoldr cargo fmt --all -- --checkCloses #146.
🤖 Generated with Claude Code