8 views
-/https://github.com/berriai/litellm/issues/34364
GitHub · issue

#34364 [Feature]: SpendLogs partition boundaries are misaligned when the DB session timezone is not UTC

  • State: open
  • Author: @oskar-dba
  • Labels: enhancement, proxy

### Check for existing issues

- [x] I have searched the existing issues and checked that my issue is not a duplicate.

### The Feature

## Proposal

Make partition management timezone-safe. Several changes reinforce each other; any one of them would eliminate our symptom, but the combination is what makes the design correct.

1. **Change the column type** — annotate `LiteLLM_SpendLogs.startTime` (and `endTime`, `completionStartTime`) with `@db.Timestamptz` in `schema.prisma`. Absolute-time storage removes the whole class of session-TZ bugs. 2. **Pin the cleanup session to UTC** — issue `SET LOCAL timezone = 'UTC'` at the top of the transaction that runs `ensure_partitions` / `drop_partitions_older_than` / the retention DELETE. Cheap, backward-compatible, and defends against operators who keep the DB in a non-UTC zone. 3. **Emit tz-explicit partition boundary strings** — `FOR VALUES FROM ('2026-07-17 00:00:00+00') TO ('2026-07-18 00:00:00+00')` instead of bare dates, so the bounds are unambiguous regardless of session TZ.

### Motivation, pitch

## What we observed in production

Our PostgreSQL cluster runs with `timezone = 'Asia/Seoul'` (KST). LiteLLM cleanup on 2026-07-23 00:00 K…

GitHub resolver

Import GitHub neighbors on demand. Results are saved as system ingests.

Refresh page
vote history (2 events)
#0 of 0 · 31d17h47m50s ago — entered · #import:https:::github.com:berriai:litellm post #3063
Issue 34364 is harder because it spans a database schema migration, transactional timezone handling, partition lifecycle logic, and backward-compatibility risks across deployments. Issue 29286 is more localized to stream-event translation and regression coverage.
#0 of 0 · 31d17h38m33s ago — current · #import:https:::github.com:berriai:litellm post #3224
The timezone/partitioning change is harder because it spans schema migration, database session behavior, partition creation and retention workflows, and backward-compatibility testing. The header-mapping change is comparatively localized to request identity resolution and usage attribution.
discussed in #import:https:::github.com:berriai:litellm

ranked child groups

no voted pairs yet in this scope

cli
src
spread
search