Skip to content

test(e2e): hold failing-request RSS to a loose ceiling over two measured batches - #47170

Merged
yuneng-berri merged 2 commits into
mainfrom
litellm_dcc925
Oct 17, 2026
Merged

yuneng-berri merged 2 commits into
mainfrom
litellm_dcc925

Conversation

@yuneng-berri

@yuneng-berri yuneng-berri commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • The failing-request RSS test fails the rc gate with no leak behind it
  • x86 allocator growth on batch 3 is about 60 MB, budget was 48 MB

How it solves it:

  • Measure batches 3 and 4 after the same two warmup batches
  • Hold each worker to a loose 200 MB ceiling over that window
  • Keep the stored-request size check, the deterministic catch for v1.100.0

User Flow

Before: a release manager gating rc/1.107.0 sees the memory test go red on every run, with nothing leaking

  1. They run the litellm-e2e Buildkite pipeline on rc/1.107.0 at 4bf1633 (build 709) or main at caad4d6 (build 710)
  2. test_failing_requests_do_not_grow_rss_or_stored_request fails with "proxy RSS grew 66.2 MB over measured batch 3 ... past the 48 MB budget"
  3. The rc is blocked on a red test that the same stack's v1.105.1 gateway also trips

After: the same run passes on a healthy proxy and still fails on a gross leak

  1. They run the same pipeline on the same commit
  2. Each worker grows about 50 to 62 MB over batches 3 and 4, under the 200 MB ceiling, so the test passes
  3. A proxy that keeps 400 KB per failed request fails with "proxy RSS grew 248.8 MB over measured batches 3-4 ... past the 200 MB ceiling"

Affected release

The test has been red on rc/1.107.0 (builds 709, 710 and earlier intermittent fails since build 398). It is a test change only, no product code changes

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • The handful of test files covering my change pass locally, e.g. uv run pytest tests/unit/<your_test_file>.py -v. Leave the suites (make test-unit-*, make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more
  • My PR passes all required CI/CD checks (e.g., lint, schema.d.ts sync check, etc.)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • Every automated review on my PR's latest commit has finished, and I have addressed or replied to each of its findings before requesting a maintainer review

Delays in PR merge?

If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).

Screenshots / Proof of Fix

Why the 48 MB budget was wrong. Two long isolated runs on the x86 release stack (Buildkite litellm-e2e-pr, only this test, 2 gateway pods, 28 batches of 300 failing requests through the router) compared the rc with the newest stable. A was rc/1.107.0 at 4bf1633 (build 1928). B was v1.105.1 at d665dc1 with the same test code (build 1929). The least-squares RSS slope per batch over batches 18 to 28 was 1.1 and 1.9 MB for A and 1.25 and 1.2 MB for B, and Python gc-tracked object counts were flat in both (A 1.612M to 1.617M, B 1.453M to 1.458M). So the rc levels off the same way the stable does and the early growth is the allocator setting new high-water marks, not a leak. Shorter isolated runs (1923, and 1924 with MALLOC_ARENA_MAX=2, which changed nothing) grew 50 to 62 MB on batch 3 alone

Growth over batches 3 and 4 per pod, the window this PR measures: 1923 61.2 and 51.5 MB, 1924 55.6 and 61.2 MB, 1928 49.3 and 61.3 MB, 1929 12.3 and 37.8 MB. The worst is 61.3 MB, well under 200 MB

Local negative control setup: the rc/1.107.0 image built from 4bf1633, one proxy with Postgres, Redis, a local HTTP sink for the logging callbacks and the CI boot command (uvicorn litellm.proxy.proxy_server:app, 1 worker). The leaking variant adds a custom callback whose async_log_failure_event appends os.urandom(400 * 1024) to a module-level list, standing in for memory kept outside the Python object graph

Before (603ba6f)

Healthy rc on the release gate

  1. Buildkite litellm-e2e build 709, rc/1.107.0 at 4bf1633, runs the suite
  2. Observed: AssertionError: proxy RSS grew 66.2 MB over measured batch 3 of 300 failing requests ... past the 48 MB budget. Build 710 on main caad4d6 fails the same way at 67.9 MB

After (6dbb65a)

Healthy rc on the local rig

  1. pytest "router/test_reliability_memory_e2e.py::TestReliabilityMemory::test_failing_requests_do_not_grow_rss_or_stored_request" against the proxy without the leaking callback
  2. Observed: 1 passed in 297.60s, with rss_batch_growth 107.0, 74.2, 38.8 and 38.4 MB for batches 1 to 4, so 77.2 MB over the measured window

Native leak on the local rig

  1. Same command against the proxy with the leaking callback
  2. Observed: AssertionError: proxy RSS grew 248.8 MB over measured batches 3-4 (600 failing requests) after 2 identical warmup batches, past the 200 MB ceiling

Type

✅ Test

Caveats (if any)

Medium

  • The ceiling misses any slow leak under ~200 MB per two batches
    • The stored-request size check still catches the v1.100.0 breadcrumb class
  • The full suite's batch 4 growth was never measured on CI
    • Batch 3 alone reached 68 MB there, so the margin is smaller than isolated runs show

Low

  • A Python object growth check was tried and dropped, a possible follow-up
    • /debug/memory/details counts uncollected garbage, a no-leak local run grew 183k objects
    • It needs an opt-in gc.collect before counting, a product change
  • The negative controls ran locally on arm64, not on the x86 gate

QA runbook

  • tests/e2e/router/test_reliability_memory_e2e.py::TestReliabilityMemory::test_failing_requests_do_not_grow_rss_or_stored_request - a few hundred requests failing through retries and a fallback do not grow any worker's RSS past 200 MB over the measured batches nor store an oversized request snapshot
    • Start a proxy with a database and the master key, then register a model group with two deployments whose api_base is an unreachable address and cooldown_time 0, plus a fallback group that refuses the same way
    • Send one failing POST http://localhost:4000/v1/chat/completions to the primary group with a 40-turn transcript and read its row back from GET /spend/logs, expect the stored request body under 64 KB
    • Read GET /debug/memory/summary until every worker has answered, then send 4 batches of 300 failing requests, reading it again after each batch
    • Expect every request to fail through the fallback, and each worker's RSS after batch 4 minus after batch 2 to be at most 200 MB
    • Sanity check: this test makes sense to add and is not hand-wavey (e.g., assert actual expected spend instead of just spend > 0) or potentially flaky

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

Note

Low Risk
Test and e2e config documentation only; no gateway or product runtime changes.

Overview
Relaxes the router failing-request RSS e2e so healthy proxies stop failing the rc gate when x86 allocator high-water marks (~60 MB on batch 3) exceed the old 48 MB single-batch budget, without dropping leak detection.

The test now runs four traffic batches (two warmup, two measured), compares each worker’s settled RSS from after warmup through batches 3–4, and asserts growth stays under E2E_MEMORY_RSS_CEILING_MB (default 200 MB, renamed from MEMORY_RSS_BUDGET_MB). The stored spend-log request size cap remains the tight check for the v1.100.0 retry-breadcrumb regression. tests/e2e/AGENTS.md documents the ceiling-over-measured-batches behavior.

Reviewed by Cursor Bugbot for commit 6dbb65a. Bugbot is set up for automated code reviews on this repo. Configure here.

…red batches

The 48 MB budget on the third batch kept failing on the x86 release gate with no
leak behind it. Isolated rc/1.107.0 and v1.105.1 stacks both grew about 60 MB on
the third batch with gc-tracked objects flat, and both levelled off to a couple of
MB per batch after twenty batches. Measure batches 3-4 against a 200 MB per-worker
ceiling instead, which a native leak of 400 KB per failed request still trips. The
stored-request size check stays the deterministic catch for the v1.100.0 leak
@yuneng-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@yuneng-berri
yuneng-berri enabled auto-merge (squash) October 17, 2026 21:04
@yucheng-berri

Copy link
Copy Markdown
Contributor

@litellm-stampbot

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 6dbb65a. Configure here.

@yuneng-berri
yuneng-berri merged commit e0514d9 into main Oct 17, 2026
89 of 91 checks passed
@yuneng-berri
yuneng-berri deleted the litellm_dcc925 branch October 17, 2026 21:05
@codecov

codecov Bot commented Oct 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

yuneng-berri added a commit that referenced this pull request Oct 17, 2026
…#47174)

* test(integration): run the bedrock mantle prompt cache and output limit wire tests on their own proxy (#47152)

* test(integration): run the bedrock mantle prompt cache and output limit wire tests on their own proxy

These two files register deployments with their own model settings on the
gateway. They now boot a module-scoped proxy on a scratch database, so their
setup cannot affect other tests that share the worker's proxy

* test(integration): seed the isolated gateway with the same router settings as the worker gateway

(cherry picked from commit 603ba6f)

* test(e2e): enable prometheus_system on the redis chaos proxy config (#47160)

#46484 moved the litellm_redis_circuit_breaker_* metrics behind service_callback prometheus_system, so the chaos proxy, which only set callbacks prometheus, stopped exposing them and the breaker assertion read 0

(cherry picked from commit 519906e)

* fix(tests): wait for every thread of a killed worker before treating it as gone (#47148)

WorkerKill returned once the victim's main thread was a zombie. On Linux the
process keeps its sockets open until its last thread exits, so a pooled
keep-alive connection to the killed worker still looked idle and the next
request through it got ECONNRESET. A zombie now counts as gone only once
num_threads() is at most 1. Where psutil cannot read threads of a zombie
(macOS) it raises ZombieProcess, a NoSuchProcess, so the old behavior holds

(cherry picked from commit 0431e75)

* test(caching): assert sync cache-hit logging without depending on thread order (#47093)

Sync success callbacks run on a thread pool, so the miss and the two
hits can reach the logger in any order. Compare counts instead of the
list order.

(cherry picked from commit 77c2ac1)

* test(e2e): hold failing-request RSS to a loose ceiling over two measured batches (#47170)

The 48 MB budget on the third batch kept failing on the x86 release gate with no
leak behind it. Isolated rc/1.107.0 and v1.105.1 stacks both grew about 60 MB on
the third batch with gc-tracked objects flat, and both levelled off to a couple of
MB per batch after twenty batches. Measure batches 3-4 against a 200 MB per-worker
ceiling instead, which a native leak of 400 KB per failed request still trips. The
stored-request size check stays the deterministic catch for the v1.100.0 leak

(cherry picked from commit e0514d9)

* fix(router): read an application profile's base model from metadata on a cache hit (#47144)

* fix(router): read an application profile's base model from metadata on a cache hit

The 1h prompt-cache pin check read base_model only from the top level of
litellm_params. On a response-cache hit the params it sees carry the base
model only under metadata.model_info, so an application-profile ARN
resolved to itself and the pin was written for 5 minutes while the wire
carried a 1h TTL. Read it through get_base_model_from_metadata, which
also checks metadata.model_info

* test(router): pin top-level base_model precedence over metadata model_info

(cherry picked from commit 1e3641a)

This branch was successfully deployed

No deployments
e2e-changed — 6dbb65a8 Deployed Oct 17, 2026 by yuneng-berri via oauth #5945
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants