fix(journaling): serialize recovery retries and preserve persistence failures - #11326
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Active work can remain incomplete when cancellation occurs during preparation or storage awaits, potentially leaving callers blocked.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
What changed in this PR
Adds lifecycle hooks and manager-owned codec resolution for journaled states, with tests, API updates, and documentation.
Changes:
- Adds readiness, validation, deletion, and terminal-failure hooks.
- Resolves codecs using the manager’s configured journal format.
- Expands lifecycle and cancellation regression coverage.
| File | Description |
|---|---|
test/Orleans.Journaling.Tests/StateManagerTests.cs |
Enables partial test organization. |
test/Orleans.Journaling.Tests/StateManagerLifecycleTests.cs |
Adds lifecycle regression coverage. |
test/Orleans.Journaling.Tests/KeyedJournalingRegistrationTests.cs |
Tests format-specific codec resolution. |
test/Orleans.Journaling.Tests/JournaledGrainCompositionTests.cs |
Updates test state readiness setup. |
src/Orleans.Journaling/JournaledStateManager.cs |
Implements lifecycle hooks and codec resolution. |
src/Orleans.Journaling/IJournaledStateManager.cs |
Adds codec-resolution API. |
src/Orleans.Journaling/IJournaledState.cs |
Defines lifecycle hook contracts. |
src/api/Orleans.Journaling/Orleans.Journaling.cs |
Updates the generated API surface. |
docs/site/src/content/docs/grains/journaling/runtime-behavior.md |
Documents lifecycle behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Code coverage
Report-only conclusion: current-main baseline stale. The newest successful coverage run tested 8efd435, not current main a68e9ed. Coverage combines every CI test matrix job, including providers, CodeGen, .NET 8/10, Linux, Windows, and macOS, using canonical physical source and branch identities. The comparison remains report-only while normal line and branch variance is calibrated. Coverage details |
a7c457d to
93fb647
Compare
93fb647 to
0237ba4
Compare
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The manager codec API described by the pull request is missing; documentation also needs a minor correction.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (1)
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Recovery retries must reset all registered state machines before replay to prevent stale in-memory data from being persisted.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (1)
Resolved since last review (1)
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
A lifecycle test incorrectly expects an acknowledgement and append for a zero-byte write path.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1



Problem
An initial recovery error permanently fences the journal manager even though recovery can start again using the existing state reset/replay contract. Owner shutdown can also be reported as a terminal journal failure, and a secondary error during failure handling can overwrite the original cause.
Changes
InitializeAsyncto retry failed recovery on the same manager and registered states. Each failed attempt reports its error to that attempt's callers; the next attempt resets recovery bookkeeping and replays from the beginning.RecoveryFailedstate is needed. Leftover signals do not trigger automatic retries.Coverage includes the actual work-loop task identity across repeated failures, eight concurrent retry callers, successful recovery, persistence and disposal; explicit retry versus idle shutdown; transient I/O and provider cancellation; repaired partial replay without duplicate list entries or unknown streams; retired-state cleanup; and existing persistence-failure, cancellation and ACK guarantees. The zero-byte write test explicitly distinguishes the initial directory-only flush from a subsequent empty write.
Scope
The public Journaling API remains unchanged. Recovery retries use the existing
Resetand replay contracts; the runtime trusts state-machine implementations. Retry timing belongs to the caller. Application and feature code owns preparation, dependencies, and cleanup; the journal manager owns initialization coordination, persistence failures, and shutdown.Messaging consumer adaptations are tracked separately in #11282, #11284, #11285, and #10693.
Current foundation diff.
Microsoft Reviewers: Open in CodeFlow