litellm/tests/test_litellm/enterprise/proxy
devin-ai-integration[bot] b2aff8be0f
fix(proxy): claim batch cost rows atomically so multi-pod polling can't double-bill (#37685)
Every pod and uvicorn worker schedules its own CheckBatchCost poller against the
shared managed-object table, so two of them can select the same completed batch in
one polling window and both write an aretrieve_batch spend log for it, counting
that batch's cost twice.

Claim the row with a compare-and-swap on batch_processed, and skip the batch when
another pod already holds it. The claim sits immediately before the spend log is
written rather than before the results fetch, because batch_processed is also what
blocks deletion of the files the fetch reads and what keeps an unbilled row
selectable by later poll cycles, so claiming up front would strand the spend of any
worker that died mid-fetch. A failed spend log write hands the row back.

Co-authored-by: Yassin Kortam <yassin@berri.ai>
2026-08-20 16:21:04 -07:00
..
__init__.py [Bug Fix] - Fix litellm_enterprise ensure imported routes exist (#17337) 2025-12-01 19:14:12 -08:00
test_afile_retrieve_returns_unified_id.py fix: afile_retrieve returns unified ID for batch output files 2026-02-14 10:07:12 -05:00
test_batch_retrieve_input_file_id.py fix: batch retrieve returns unified input_file_id 2026-02-14 11:24:08 -05:00
test_batch_retrieve_registers_missing_output_file_id.py fix(proxy): register managed batch output files on terminal retrieve (#34092) 2026-08-05 16:38:49 -07:00
test_batch_retrieve_returns_unified_input_file_id.py fix(proxy): register managed batch output files on terminal retrieve (#34092) 2026-08-05 16:38:49 -07:00
test_batch_update_db_managed_output_file_id.py fix(batches): keep batch state in sync on a poll without claiming attribution (#34456) 2026-08-08 16:01:47 -07:00
test_deleted_file_returns_403_not_404.py Addressed greptile comments to extract common helpers and return 404 2026-02-16 07:58:04 -05:00
test_enterprise_routes.py [Bug Fix] - Fix litellm_enterprise ensure imported routes exist (#17337) 2025-12-01 19:14:12 -08:00
test_file_deletion_blocking.py Fixes based on greptile reviews 2026-02-18 12:19:11 +05:30
test_managed_files_access_check.py fix(proxy): claim batch cost rows atomically so multi-pod polling can't double-bill (#37685) 2026-08-20 16:21:04 -07:00
test_managed_files_hook.py fix(batches): persist the creating key and tags on managed batches created via /v1/batches 2026-08-15 12:45:00 -07:00