refactor(partitions): make purge recovery testable with SimStorage - #4240
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #4240 +/- ##
=============================================
- Coverage 87.53% 70.73% -16.80%
- Complexity 1575 1576 +1
=============================================
Files 1283 1282 -1
Lines 223461 198202 -25259
Branches 186824 161567 -25257
=============================================
- Hits 195605 140207 -55398
- Misses 23141 53372 +30231
+ Partials 4715 4623 -92
🚀 New features to boost your workflow:
|
|
Suggested review path: start with the two controls, then follow the shared production code they exercise. This PR connects purge completion and bookmark recovery to the existing A consumer offset is a bookmark: a saved offset of The two test scenarios make this observable:
Both scenarios cover individual consumers and groups under In the first test, the fixture writes and explicitly syncs the bookmarks and messages before the crash. No data loss is expected. “Recovery” means creating a new partition and loading its state from the surviving files. The simulated crash discards unsynced changes, preventing recovery from relying on cached writes. This control also rejects a recovery implementation that always returns empty bookmark maps. Because the fixture explicitly syncs under both policies, it does not claim that every ordinary In the second test, the partition starts at the purge completion phase, with message history already reset and old bookmarks still present. It also creates bookmark files absent from the live maps, requiring the directory sweep to find them. Assertions check that completion clears the live bookmarks, durability tracking, and files. After saving fresh messages and simulating power loss, the test reloads the completion marker and consumer state into a new partition, then checks the actual messages returned by For the production changes, the useful review points are:
These are controls for successful cleanup and recovery. They exercise production bookmark logic against simulated storage, but do not inject sync failures, exercise the message reset phase or purge retries, or run full server startup. The known bug can therefore remain while both tests pass. The remaining regression work must introduce the relevant directory sync failure and check recovery and retries, including preservation of acknowledged fresh messages. |
|
@diegomrsantos please rebase - i introduced a small-ish server refactor in #4089 |
Production purge and offset recovery need to run against simulated storage so power loss checks use the same error decisions and recovered state as the server. Share cleanup and completion logic through DurableStorage and add recovery controls for both consumer offset durability policies. Preserve the current behavior after cleanup errors.
b39042a to
041e00b
Compare
|
@diegomrsantos could you please analyze if this problem with purge is related to failing bdd tests in #3608 ? |
|
@diegomrsantos i will check this PR in ~1h |
hubcio
left a comment
There was a problem hiding this comment.
looked at the purge and offset recovery extraction. the shared cleanup, completion and recovery paths keep the order and the error handling from master, and both new controls run under both durability policies against the simulated filesystem. one warning stands, and it is the #4128 shape: the offset directory sweep is silent on a failed scan and still records the generation, so the fix belongs there and not in this refactor. the rest are small cleanups.
Keep purge failure handling unchanged while making directory scan and generation probe errors visible. Remove unused recovery abstractions and reuse the existing offset filename parser.
The disk wrapper is gone, so the storage suffix no longer distinguishes two variants. Update the reader name, callers, tests, and documentation link.
|
Thanks for the reviews, @hubcio and @mmodzelewski! |
|
@hubcio @mmodzelewski could one of you rerun the C++ BDD job? It failed with a 504 while downloading a Bazel dependency, before the tests started. I don't have permission to rerun it. |
|
i will restart once all jobs are finished |
Which issue does this PR address?
Closes #4239.
Relates to #4128 and #4130.
Rationale
The existing storage purge test uses its own cleanup sequence, while cluster simulation retains consumer offsets in memory across restarts. Testing recovery after power loss needs the production cleanup decisions and state reloaded from the simulated filesystem.
What changed?
Production purge now shares its offset cleanup and completion phase with a focused
SimStorageharness throughDurableStorage, preserving the current behavior after errors, including #4128. The harness starts after the message reset and reloadspurge.gen, individual consumer offsets, and group offsets through shared production recovery code.Controls cover both offset durability policies, cleanup of files absent from the live maps, and
Nextreturning the complete fresh history after power loss. Fresh messages are durable before the crash, and their persistence leaves the separate offset directories untouched; the failure regression and checks of retries with acknowledged fresh writes remain followup work.Local Execution
cargo fmt --allandcargo sort --no-format --workspace.cargo clippy --offline --all-features --all-targets -- -D warningsacross the workspace.cargo test --offline -p journal -p partitions -p server -p simulator --lib: 1,012 passed, 7 ignored on macOS. The server suite ran outside the sandbox to allow its local HTTP listener.taplo fmt --checkover all tracked TOML files.--cap-lints warn. The strict documentation link check encounters existing unresolved references in unmodified journal and server files.AI Usage
Codex generated the implementation and tests and drafted this description. Local verification is recorded above.