mirror of
https://github.com/BerriAI/litellm.git
synced 2026-12-04 01:48:57 +00:00
* fix(accounting): let one pod at a time deliver spend Every pod ran the delivery loop on each flush. When most spend belongs to a few teams, the pods queue on the same team advisory lock, the waiters hit lock_timeout and roll back, and their rows move to the one-row-per-transaction retry path. Take a short-lived delivery lock around the fresh and retry loops so only one pod claims deliveries at a time. The maintenance lock is untouched, so an orphaned maintenance lock still cannot stall delivery. A crashed holder delays delivery by at most the lock TTL, and without Redis delivery behaves as before. Relates to #55172 Co-Authored-By: AaronHowell <111272993+AaronHowell@users.noreply.github.com> * fix(accounting): keep the delivery lock as long as one batch may run A single delivery batch runs in a transaction with a 60 second timeout, so a 30 second lock could expire while its holder was still delivering and let a second pod start. Use 60 seconds so the lock outlives any one batch. Co-Authored-By: AaronHowell <111272993+AaronHowell@users.noreply.github.com> * fix(accounting): leave lock-timed-out spend deliveries for the next flush instead of the retry queue Since every pod delivers spend at once, a delivery that times out waiting for a hot team or key row bumped attempts on its whole batch, which moved up to 500 rows into the one-row-at-a-time retry queue. A lock timeout means the batch never applied and rolled back, so leave the claimed rows as they were and let the next flush deliver them in a batch. This replaces the one-pod-at-a-time delivery lock from #55173, which stopped the retries but delivered a third to a half fewer rows per minute than concurrent pods. Thanks to @Bytechoreographer for tracking the stuck rows down to concurrent delivery. * fix(accounting): keep backoff for retried deliveries that hit a lock timeout Only a new batch is left as it was after a lock timeout. A delivery already in the retry queue backs off again as before, so one busy row no longer holds up the other retries behind it. The worker now logs how many requests it left for the next flush. * fix(accounting): never park a delivery for a lock timeout A lock timeout that Postgres reports in another language came back as a plain DataError, which counted as a permanent failure, so a retried delivery on its last attempt was parked. Lock timeouts now always back off and retry. * fix(accounting): count lock-timed-out deliveries on /metrics * fix(accounting): split a lock-timed-out batch by team so one held lock defers only that team A fresh batch that times out on a team lock, or whose transaction expires, is split by the teams it charges. Each team's deliveries are claimed again and applied in their own transaction, so a long-held lock on one team only defers that team's rows, and those rows step back 5-15 s so newer deliveries go first. After two contended teams the rest of the batch waits for the next flush untried. * fix(accounting): back off an expired single-team batch, cap the split at 5 s, and keep committed teams when the database drops * fix(accounting): name the split limit in the deferred delivery log --------- Co-authored-by: Rick <26716961+Bytechoreographer@users.noreply.github.com> Co-authored-by: AaronHowell <111272993+AaronHowell@users.noreply.github.com> |
||
|---|---|---|
| .. | ||
| image | ||
| migrations | ||
| test_alerts.py | ||
| test_auth_profile_encryption_migration.py | ||
| test_chunked_in_lists.py | ||
| test_cleanup_transactions.py | ||
| test_control_plane_runtime_config.py | ||
| test_global_spend_refresh_writer.py | ||
| test_harness_lifecycle.py | ||
| test_managed_file_flat_ids_index.py | ||
| test_mcp_server_events_column.py | ||
| test_migration_entrypoint.py | ||
| test_partition_transactions.py | ||
| test_performance_alerts.py | ||
| test_prisma_engine_port.py | ||
| test_prisma_engine_real_io.py | ||
| test_prisma_migration_lock.py | ||
| test_proxy_boot_without_general_settings.py | ||
| test_proxy_database_lifespan.py | ||
| test_reader_writer_regeneration.py | ||
| test_request_log_indexes_at_boot.py | ||
| test_roi_observed.py | ||
| test_roi_sync_store.py | ||
| test_scheduled_job_runs.py | ||
| test_skill_publication.py | ||
| test_skill_submissions.py | ||
| test_spend_lock_order.py | ||
| test_spendlogs_delivery.py | ||
| test_spendlogs_ledger_parity.py | ||
| test_transaction_atomicity.py | ||
| test_v1_migration_error_logging.py | ||