litellm/tests/test_litellm/proxy/db/db_transaction_queue
Yassin Kortam a992ed18df
feat(spend_logs): opt-in native Postgres partitioning for SpendLogs retention (#29466)
High-volume deployments see LiteLLM_SpendLogs grow unbounded because
retention via DELETE leaves dead tuples that autovacuum cannot reclaim
fast enough. With a range-partitioned table, retention drops whole
partitions instead: an instant metadata operation that returns disk to
the OS immediately.

The feature is gated behind general_settings.use_spend_logs_partitioning
(default false). With the flag off, the cleanup job never queries the
catalog and behaves exactly as today. With it on, the job verifies the
table is partitioned, pre-creates upcoming partitions, and drops expired
ones; expired rows the drops cannot reach (DEFAULT partition, partitions
spanning the cutoff) are still deleted row-wise so retention is never
bypassed. If the table is not partitioned it falls back to batched
DELETE only.

Converting an existing table is a manual, documented operation in
db_scripts/partition_spend_logs.sql; db_scripts/unpartition_spend_logs.sql
rolls it back. Both scripts rename the old table's indexes aside before
recreating them, since a table rename keeps the schema-unique index names
and would otherwise silently skip the CREATE INDEX IF NOT EXISTS block.

Granularity and pre-create lookahead are tunable via
SPEND_LOG_PARTITION_INTERVAL (day/week/month, invalid values fall back to
day) and SPEND_LOG_PARTITION_PRECREATE_AHEAD.
2026-06-11 11:02:42 -07:00
..
test_base_update_queue.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_daily_spend_update_queue.py
test_pod_lock_manager.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_redis_update_buffer.py [Fix] Preserve in-memory spend updates when Redis rpush fails 2026-04-22 14:10:40 -07:00
test_spend_logs_partition_manager.py feat(spend_logs): opt-in native Postgres partitioning for SpendLogs retention (#29466) 2026-06-11 11:02:42 -07:00
test_spend_update_queue.py
test_tool_discovery_queue.py feat(proxy): tool policies - auto-discover tools + policy enforcement guardrail (#22041) 2026-02-24 16:27:06 -08:00