[Fix] Spend Update Queue Aggregation Never Triggers with Default Presets#21963
Merged
yuneng-jiang merged 1 commit intomainfrom Feb 24, 2026
Merged
[Fix] Spend Update Queue Aggregation Never Triggers with Default Presets#21963yuneng-jiang merged 1 commit intomainfrom
yuneng-jiang merged 1 commit intomainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Greptile SummaryThis PR fixes a bug where
Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| litellm/constants.py | Reordered LITELLM_ASYNCIO_QUEUE_MAXSIZE before MAX_SIZE_IN_MEMORY_QUEUE and changed default from 2000 to 80% of LITELLM_ASYNCIO_QUEUE_MAXSIZE (800). Correctly fixes the dead code bug. |
| litellm/proxy/db/db_transaction_queue/base_update_queue.py | Added a startup warning when MAX_SIZE_IN_MEMORY_QUEUE >= LITELLM_ASYNCIO_QUEUE_MAXSIZE, catching user misconfiguration via environment variables. Clean defensive check. |
| tests/test_litellm/proxy/db/db_transaction_queue/test_base_update_queue.py | Added mock-only test verifying the misconfiguration warning is emitted. No network calls; patches module-level constants and logger correctly. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["add_update() called"] --> B["await queue.put(update)"]
B --> C{"queue full?\n(qsize == LITELLM_ASYNCIO_QUEUE_MAXSIZE)"}
C -- Yes --> D["BLOCKS (await)"]
D --> B
C -- No --> E{"qsize >= MAX_SIZE_IN_MEMORY_QUEUE?"}
E -- Yes --> F["aggregate_queue_updates()\nFlush + re-enqueue aggregated items"]
E -- No --> G["Return"]
F --> G
style C fill:#ffcc00,stroke:#333
style E fill:#66ccff,stroke:#333
style D fill:#ff6666,stroke:#333
style F fill:#66ff66,stroke:#333
Last reviewed commit: a9c44d8
damhau
pushed a commit
to damhau/litellm
that referenced
this pull request
Feb 26, 2026
[Fix] Spend Update Queue Aggregation Never Triggers with Default Presets
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Relevant issues
Summary
MAX_SIZE_IN_MEMORY_QUEUEdefaulted to2000whileLITELLM_ASYNCIO_QUEUE_MAXSIZE(the hard cap on the underlyingasyncio.Queue) defaulted to1000. Becauseasyncio.Queueblocks on.put()once it reaches itsmaxsize,qsize()can never reach2000, so the aggregation branch inSpendUpdateQueue.add_update()was dead code.Fix
LITELLM_ASYNCIO_QUEUE_MAXSIZEbeforeMAX_SIZE_IN_MEMORY_QUEUEinconstants.pyso the former can be referenced in the latter's default.MAX_SIZE_IN_MEMORY_QUEUEnow defaults toint(LITELLM_ASYNCIO_QUEUE_MAXSIZE * 0.8)(800), ensuring the aggregation threshold is always reachable.BaseUpdateQueue.__init__that fires wheneverMAX_SIZE_IN_MEMORY_QUEUE >= LITELLM_ASYNCIO_QUEUE_MAXSIZE, catching any misconfiguration set via environment variables.Testing
Added
test_misconfigured_queue_thresholds_warnsintests/test_litellm/proxy/db/db_transaction_queue/test_base_update_queue.py— patches both constants to simulate the broken configuration and asserts the warning is emitted.Type
🐛 Bug Fix
✅ Test