Repository navigation
fix(gateway): prevent body budget starvation (Core 0.98.1) - #407
Merged
Merged
Conversation
Immediate budget refusal lets small requests keep overtaking a large conversation on every retry. Queue admission before reading, reserving a known uncompressed upper bound in advance while serializing growth of unknown and compressed bodies to avoid partial-reservation deadlocks. Bound waits and idle uploads at 30 seconds, release CPU slots while waiting for decompression space, and return compressed-input headroom promptly. Retain the existing memory policy, size limits and retryable 429 contract. Release Core 0.98.1 with regression coverage and updated server docs. Addresses #403; the original field incident still lacks runtime evidence.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Large bodies can repeatedly receive Core's memory-budget 429 while later small requests continue to enter. This changes admission to wait in FIFO order for space, with a 30-second bound, so an existing large waiter cannot be overtaken by new small bodies.
Known-size uncompressed uploads reserve their complete bounded size before reading and remain concurrent. Only one unknown-size or compressed body can grow while holding a partial reservation, avoiding partial-body deadlocks. When decompression exhausts the budget, it releases the failed output and CPU slot, waits for exclusive space, and retries at most once. Completed decompression returns the compressed-input headroom; cancellation, idle uploads and timeouts release their reservations. Budget exhaustion still returns the existing retryable 429 and now logs occupancy.
Bumps Core to 0.98.1 and documents the admission behavior and release. Addresses #403's reproduced starvation mechanism; the original deployment's response body, version and budget occupancy remain unavailable, so the field incident's cause is not asserted as confirmed.
Validation:
cargo fmt --all -- --checkandcargo clippy --workspace --all-targets -- -D warningspassed.cargo nextest run --workspace --profile ci: 4510 passed, 16 skipped; workspace doc tests passed.scripts/smoke.sh: 87 passed, 0 failed; release-note tests: 17 passed.