From 085d5f5d4e0ba321eecf43f677c7b2f16a01dfd7 Mon Sep 17 00:00:00 2001 From: ryan-crabbe-berri Date: Sat, 29 Aug 2026 14:18:41 -0700 Subject: [PATCH] docs(proxy): state that the cross-pod window seed gap over-counts, never under-counts --- litellm/proxy/db/budget_window_spend_writer.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/litellm/proxy/db/budget_window_spend_writer.py b/litellm/proxy/db/budget_window_spend_writer.py index d8c2c7c2695..f9188f95cfd 100644 --- a/litellm/proxy/db/budget_window_spend_writer.py +++ b/litellm/proxy/db/budget_window_spend_writer.py @@ -11,9 +11,13 @@ Seeding a row that does not exist yet reads LiteLLM_SpendLogs once, excluding the requests whose increments are in the same batch so neither source counts them twice. One gap survives that exclusion: without the Redis transaction buffer every pod flushes its own increments, so a row seeded by one pod can -miss increments still queued on another. That is bounded by a single flush -interval, happens at most once per window row, and errs toward under-counting -for that interval only. +include spend logs whose increments are still queued on another pod, and those +increments are added again when that pod flushes. That is bounded by a single +flush interval, happens at most once per window row, and only ever over-counts: +the seed never omits spend, because every increment not yet in the row still +reaches it on its own pod's next flush. A row therefore lags real spend by at +most one flush interval of queued increments, the same lag the SpendLogs +aggregate it replaces (and every other spend column) already has. """ from collections.abc import Sequence