fix(queue): preserve JSONL boundaries when recovering inflight rows - #371
DivyamTalwar wants to merge 1 commit into
Conversation
|
Understand this PR’s impact Explore downstream dependencies and potential security impact with Blast Radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: activeloopai/hivemind/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 4 included reviews per hour; 1 remains after this review. 📝 WalkthroughWalkthroughThe queue recovery path now checks the existing queue tail before appending inflight content. It adds a separator only when required and closes the shared file descriptor after the append. Tests cover partial, complete, terminated, stale, and absent queue states. ChangesSession queue recovery
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~15 minutes Change: Bug fix · Severity of issue fixed: Medium Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 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 |
Summary
Fixes #370.
When an upload fails, requeueInflight() appends the old inflight bytes directly to the producer replacement queue. If that replacement ends in a partial JSON record or a complete record without its trailing newline, the first recovered row is concatenated to it. The next drain treats the combined line as malformed and loses a previously durable row.
Change
Inspect and append through the same a+ descriptor and insert a separator only when the nonempty replacement queue is unterminated. Reuse the existing newline helper; close the descriptor in finally and remove inflight only after append succeeds. Empty and already terminated queues do not gain an extra byte.
Regression evidence
The five-case negative-control matrix has three failing cases and two passing controls on unchanged source. With the patch, all five pass. Tests exercise failed uploads with partial/complete/terminated replacement tails, stale inflight recovery, and absent replacement queues, then verify row identities and no second-flush replay. The Linux surrounding run passes 48 tests; independent macOS review passes 43 queue and append-atomicity tests.
Version Bump
No release is requested from this contributor PR. Package versions and the lockfile are unchanged.
Test plan
728aa7de466e51ba05174eb5ec7e92576456a48bpasses the full Node 22/Linux suite with coverage: 5854 tests passed, zero failed.Exact commands, logs, and validation artifacts. This is an independent branch gate, not a result borrowed from a stacked feature branch.
Limits
This is a record-boundary fix, not an outage-isolation, queue-capacity, cross-workspace migration, or distributed-lock redesign. Crash-after-append-before-removal and disk-failure semantics are unchanged. Existing open PRs #61 and #65 were checked at their actual head source: both still perform the unseparated append and do not include this fix.
The full isolated macOS baseline is not clean (19 failures and 10 skips before these changes); a clean full macOS suite is not claimed. Local scoped evidence and the full Linux gate are reported separately. Regression tests use synthetic files and mocked network/worker boundaries, not real user credentials, customer transcripts, or live model calls.
Summary by CodeRabbit
Bug Fixes
Tests