feat: a database connection pool behind DB_POOL (off in production)

Every db.connect() opened a new Postgres connection; with DB_POOL=on each
process keeps a psycopg_pool pool (DB_POOL_SIZE, default 20, 10 s
acquisition timeout, dropped connections replaced) with the same
commit/rollback contract. Production stays off until switched in Portainer;
the local stack and CI run with it on. Two nested acquisitions that ran on
every board load and in audits now reuse the caller's connection.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-11-09 17:57:42 -03:00
parent 085c2d0009
commit 5b7e95ad86
17 changed files with 190 additions and 16 deletions

View File

@@ -17,6 +17,9 @@ SITE_PORT=8080
KANBAN_PORT=8081
# API processes: 2 by default; 1 runs one process, as before. API only.
API_WORKERS=2
# Database connection pool: off keeps one connection per block, as before.
DB_POOL=off
DB_POOL_SIZE=20
R2_ENDPOINT=TBD
R2_PUBLIC_ENDPOINT=TBD