Repository navigation
feat(journaling): configure volatile journal snapshot thresholds - #11471
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The implementation matches the described policy and includes comprehensive validation and behavioral coverage.
0 open findings
What changed in this PR
Adds configurable append-count and byte thresholds for volatile journal snapshots.
Changes:
- Adds validated default and named-provider snapshot options.
- Tracks and resets per-journal append counters.
- Adds documentation, API surface updates, and comprehensive tests.
| File | Description |
|---|---|
src/Orleans.Journaling/VolatileJournalStorageOptions.cs |
Defines threshold options and validation. |
src/Orleans.Journaling/VolatileJournalStorage.cs |
Implements per-journal counters and snapshot requests. |
src/Orleans.Journaling/JournalingHostingExtensions.cs |
Registers default and named options. |
src/Orleans.Journaling/README.md |
Documents threshold behavior. |
src/api/Orleans.Journaling/Orleans.Journaling.cs |
Updates the generated public API surface. |
docs/site/src/content/docs/grains/journaling/configuration.md |
Adds configuration guidance. |
docs/site/src/content/docs/grains/journaling/snippets/journaling/JournalingConfiguration.cs |
Adds a configuration example. |
test/Orleans.Journaling.Tests/VolatileJournalStorageProviderTests.cs |
Tests boundaries, resets, cancellation, and isolation. |
test/Orleans.Journaling.Tests/KeyedJournalingRegistrationTests.cs |
Tests named options and replay integration. |
test/Orleans.Journaling.Tests/StateManagerTests.cs |
Preserves the retirement test’s compaction frequency. |
🧠 Review effort: Balanced
💡 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: regressed. The current-main baseline is commit 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 |
7d9abac to
f180255
Compare
Volatile journal storage currently requests compaction based on its stored segment count. That makes snapshot frequency implicit and provides no byte-based policy for larger appends.
Add
VolatileJournalStorageOptionsand default/named provider configuration. Each journal requests a snapshot when either its successful append count or appended encoded bytes reaches the configured threshold. The deliberate defaults are 100 appends or 1 MiB (1,048,576 bytes), replacing main's>10stored-segment trigger. Positiveintappend limits and positivelongbyte limits are supported.Providers capture the configured limits at construction. Named/default options pipelines apply before that boundary; the store owns journal-wide counters shared across handles and isolated across journals and providers. The state manager observes the request before its next write, materializes the current state snapshot, awaits replacement, and acknowledges the write. Successful snapshot replacement or deletion resets both counters; snapshot bytes are excluded from append history. Delete/recreation resets history. The existing retirement test explicitly selects its required snapshot frequency.
Threshold checks and counter updates use constant-time accounting under the existing store lock. The stored list count and each copied byte-array length fit in
int, bounding the appended-byte sum belowlong.MaxValue. Retained memory includes the latest snapshot, encoded append history including the crossing append, and provider bookkeeping. Storage continues to copy main's borrowed input buffers and preserves existing format dispatch (V1 marker1and the V0 reader).Include deterministic exact-threshold, cancellation, snapshot/reset, multi-segment borrowed-input, isolation, option-validation, concurrent shared-handle, separate options-pipeline capture, and JSON/binary replay cases. Source-backed configuration guidance and the generated additive API surface accompany the implementation. Normal Release packing passes the released compatibility baseline unchanged.
This standalone extraction was carved from original base
48f3aaa47fc18123db4109063af591f315e6f9cbthrough source9c1ef0f2feb258c1764de5f408d89c53e7e63f9f(initial policy commitbb124aaf6b5bb294f492a44941b90202a841b818), and is now rebased onto mainb3b76e2ab207f00e664e0167cd733800cd60379d. The latest repository contract/performance review retained the focused policy design and added explicit construction/concurrency guarantees. Retained-storage/page-pool optimization, writer/manager ownership changes, hooks, dictionary lifecycles, messaging, timers, and BufferPackage stay outside this PR.Microsoft Reviewers: Open in CodeFlow