Skip to content

fix: API OOM 137 - add /api/livez, connection pooling, close pool on shutdown - #33

Merged
surrealwolf merged 1 commit into
mainfrom
fix/api-oom-137-probes-memory-pooling
Feb 9, 2026
Merged

fix: API OOM 137 - add /api/livez, connection pooling, close pool on shutdown#33
surrealwolf merged 1 commit into
mainfrom
fix/api-oom-137-probes-memory-pooling

Conversation

@surrealwolf

@surrealwolf surrealwolf commented Feb 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

Addresses API pods exiting with error 137 (SIGKILL) caused by liveness probe timeouts and potential OOM.

Changes

1. Lightweight liveness probe (/api/livez)

  • Add /api/livez endpoint that returns {"status": "ok"} without hitting the database
  • Intended for Kubernetes liveness checks - avoids unnecessary DB load and timeouts when the app is alive but DB is slow
  • Keep /api/health for readiness (includes DB and upstream status)

2. DB connection pooling

  • Replace per-request psycopg2.connect() with ThreadedConnectionPool (min 2, max 10 connections)
  • Reduces connection churn and exhaustion under load
  • Close pool on app shutdown (app_readonly lifespan) and collector shutdown (main.py)

3. Tests

  • Add tests/test_app_readonly.py with tests for /api/livez and /api/health

Deployment

Requires accompanying k8s changes in high-command-ui:

  • Point liveness probe at /api/livez
  • Increase memory limit (1Gi → 2Gi)
  • Increase probe timeouts

Related PR: DataKnifeAI/high-command-ui#23

…shutdown

- Add /api/livez lightweight liveness probe (no DB) for k8s liveness checks
- Add DB connection pooling (ThreadedConnectionPool, 2-10 conns) to reduce
  connection churn and avoid exhaustion under load
- Close connection pool on app/collector shutdown
- Add tests for livez and health endpoints

Co-authored-by: Cursor <cursoragent@cursor.com>
@surrealwolf
surrealwolf merged commit fec8dfe into main Feb 9, 2026
9 checks passed
@surrealwolf
surrealwolf deleted the fix/api-oom-137-probes-memory-pooling branch February 9, 2026 05:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant