Skip to content

v3.2.2 - fix: spend-logger memory leak, CTE idempotency, and virtual key cache bounding

Choose a tag to compare

@tuxevil tuxevil released this 21 Aug 12:09
· 82 commits to main since this release

What's Changed

This release resolves a critical memory leak in file-based storage mode, introduces atomic and idempotent PostgreSQL spend log tracking via CTEs, bounds the virtual-key in-memory cache, and surfaces official per-model context windows.

Fixed

  • Spend-logger memory leak in file-based storage mode: When running without PostgreSQL, flushSpendLogs() returned early without draining the spend log queue, leading to unbounded heap memory accumulation. logSpend() now short-circuits and clears queue when PostgreSQL is not configured (#22 by @javargasm).
  • Atomic PostgreSQL spend log insert & daily aggregation via CTE: Combined rotator_spend_logs insert and rotator_daily_spend upsert into a single atomic Common Table Expression query. Re-attempted inserts with existing request_id values produce 0 rows from ins_log, guaranteeing strict idempotency without double-counting on retries. On DB errors, only uncommitted logs are re-enqueued under a strict FIFO cap (MAX_QUEUE_CAP = 100) (#22 by @javargasm).
  • Virtual Key cache bounded: Added KEY_CACHE_MAX = 500 with 1-minute TTL and FIFO eviction to keyCache in src/virtual-keys.ts, preventing memory exhaustion from negative lookup caching and key scanning (#22 by @javargasm).
  • /v1/models no longer reports the outdated 500K Claude context window.

Added

  • Official per-model context windows surfaced across providers: Published upstream context windows for Claude (Opus 4.6 / Sonnet 4.6 → 1M, Opus 4.5 / Sonnet 4.5 → 200K), Google Gemini (3.1 Pro, 3 Pro, 3 Flash variants, 2.5 Pro/Flash → 1M each), and gpt-oss-120b (131,072) via src/providers/google-antigravity/catalog.ts.
  • /api/show lookup for Ollama model context windows: Dynamic context length lookup from Ollama.
  • ModelSpec.contextWindow: Context window spec exposed across /v1/models endpoints.

Changed

  • OpenAI Codex catalog updated to GPT-5.6 family official 1.05M window.
  • OpenCode Zen catalog exposes per-model context helper.
  • Claude Opus 4.6 / Sonnet 4.6 context window in MODEL_CATALOG raised to 1M.

Full changelog: https://github.com/tuxevil/tuxevil-rotator/blob/main/CHANGELOG.md