fix(storage): preserve publication headroom during collection ingest - #229
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (5)
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review. WalkthroughThe change adds an allocation estimate for grouped-object publication and uses it in collection-ingest merge admission. Tests check that probing does not create an index entry and that the estimate drops to zero after publication preparation. ChangesPublication allocation admission
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to The ingest change accounts for the destination publication allocation before merging, with publication retaining its own admission check. No actionable merge-blocking risk remains. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change preserves existing memory limits and publication checks while reducing out-of-memory failures during restore. No new security weakness was identified in the inspected paths, but broader access-control and deployment behavior were not assessed. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
🚥 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. A rabbit checks the key’s new space, Comment |
Context
Fix the main-branch RESTORE OOM exposed by both architectures in PR #228's CI run. The same
GroupedStreamE2e.LargeRepliesKeepSnapshotsAndDeletedHistoryfailure reproduces on unmodified maina6e93d3d.Behavior before and after
The collection ingest batching probe covered decoded input, page construction, directories and retirement receipts, but omitted the allocation needed to publish the destination into the grouped side index. A cold arena may need a complete span for its first entry. The batch could therefore consume the headroom needed to finish publication and fail with
OOM grouped index exceeds maxmemory.The debugger captured a 1,163,328-byte publication allocation with only 1,140,345 bytes of worker headroom remaining. The ordinary Redis reply hides this internal reason behind the generic maxmemory error.
The probe now includes the destination index's current allocation requirement. It flushes a smaller batch when needed, allowing the existing 256 MiB test to complete. There is no fixed input-batch size limit, memory-limit increase or weakened assertion.
Implementation
PublicationAllocationBytesprobe using the same arena/table sizing asPreparePublish; existing slots need no allocation.Design decisions and alternatives
Use the allocator's current requirement rather than a guessed constant or fraction of available memory. The probe is not a reservation across coroutine suspension; actual publication retains its admission check.
Documentation and comments
API and batching invariants are documented beside the code. Architecture is unchanged: this corrects a local headroom estimate within the existing admitted atomic-ingest flow.
Test plan
Builds completed before tests ran. Debug configuration with fault injection, matching CI:
The actual invocations supplied an absolute server path and
LAVIK_TEST_DATA_DIRon the test volume. Results: 40 unit tests and 5 end-to-end tests passed.pre-commit run --filespassed for all five changed files;git diff --checkpassed.Risk assessment
An additional owner-local lookup per decoded page and potentially earlier flushing for a cold destination. Concurrent allocations can still exhaust memory after a probe; downstream admission remains authoritative. No durable format, transaction visibility or rollback change.
Rollback plan
Revert this single commit; no data migration is needed.
Reviewer guide
Start at the ingest probe, then compare
PublicationAllocationByteswithPreparePublishand theInserthelper's allocation sizing.Follow-up work
Independent of the throughput work in #228. That PR can incorporate this fix through main after merge.
Summary by CodeRabbit