fix(collector): finalize scheduled LOB segments off async loop - #839
Conversation
📝 WalkthroughWalkthroughThe Binance LOB archiver now closes rotated segments in asynchronous blocking tasks. Session rotation and shutdown collect pending finalizers and propagate errors without blocking health or event consumption. ChangesAsynchronous segment finalization
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@rust_hft/tools/collector/src/bin/binance-lob-archiver.rs`:
- Around line 2210-2218: Remove the test-only synchronous rotation helper used
by rotate_segment, including its inline closing_segment.close() lifecycle.
Update each caller to perform rotation through begin_segment_rotation,
finish_segment_rotation, and collect_segment_finalizer, preserving asynchronous
finalizer handling and existing rotation behavior.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 65e833cf-c0e8-4e9a-8824-e17da8564364
📒 Files selected for processing (1)
rust_hft/tools/collector/src/bin/binance-lob-archiver.rs
48f57db to
99fc1a6
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 48f57db3f8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
99fc1a6 to
29e6489
Compare
29e6489 to
73d6998
Compare
Change contract
Move scheduled segment finalization (flush/sync/zstd/hash/manifest) onto one Tokio blocking task so the async consumer can keep processing events and publishing health. Keep at most one pending finalizer; poll completed tasks every loop without waiting, defer a due rotation while the previous task is unfinished, collect the completed prior task before the next actual rotation and before session return, and propagate task or close errors fail-closed. All post-spawn loop errors route through the common shutdown path so a pending task is never detached. Segment schema, replay/continuity rules, zstd settings, upload behavior, source-delay gate, watchdog, and runtime configuration are unchanged.
Issue relationship
Closes #838
Out of scope
No schema, threshold, upload, deployment, ECS/OSS, Gate, cutover, Live, or runtime changes.
Dependencies and merge order
None; based on exact origin/main e557059.
Focused validation
Rollout and rollback
None; code-only change. Rollback is reverting this single commit.
Scope exception
None; one source file, one behavior.