Commit Graph
6 Commits
Author SHA1 Message Date
AndreyandClaude Fable 5 4b89c45560 🚑 fix(db): pool Postgres connections instead of CONN_MAX_AGE under ASGI
Persistent-соединения (CONN_MAX_AGE=60) осиротевали в короткоживущих
потоках asgiref ThreadSensitiveContext: Django закрывает старые соединения
только из потока-владельца, поток умирает после запроса, соединение
остаётся idle навсегда. На prod это дало 85 idle custocrm_app за 4,5 ч и
исчерпание max_connections=100 (500 на /api/v1/auth/login/, 2026-07-17).

Фикс: CONN_MAX_AGE=0 + нативный psycopg pool на процесс (Django 5
OPTIONS["pool"]): на выходе из запроса соединение возвращается в пул
(putconn) независимо от судьбы потока, суммарное число ограничено
max_size. Defaults: min 1 / max 4 / timeout 10s; env-переопределение
CUS_DB_POOL_MIN/MAX/TIMEOUT, CUS_DB_POOL_MAX=0 отключает пул. Worst case
по всем сервисам (app 3w + platform 3w + admin 2w + worker, оба alias)
~72 < 100. В testing пул выключен (pytest-django + TEST MIRROR).

Интеграционная проверка: 60 запросов в короткоживущих потоках ->
ровно 4 серверных соединения. RLS не затронут: tenant-контекст ставится
через set_config(..., local=true) внутри транзакции.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-17 20:28:34 +03:00
Andrey d5e9bed451 🚑 fix(ai)!: hand off failures and migrate env prefix to CUS_ 2026-07-17 14:10:06 +03:00
Andrey 7bbf685735 ✨ feat(ai): add managed CustoAI and BYOK switching 2026-07-17 10:48:57 +03:00
Andrey c9ac556ae4 📝 docs(cutover): add C04–C07 production cutover runbook and config
RUNBOOK-CUSTOCRM-0002 covers the in-place cutover of the existing Edevs
production DB onto C04–C07: RLS runtime roles, S3 tenant storage, PlanVersion
publication, STARTUP subscription and domain cutover. Owner decisions recorded
2026-07-16 (VK Cloud S3, smtp.mail.ru, web/TURN IPs, turn.custocrm.ru realm).

- INVENTORY-0009: mark storage cycle and membership-count debt resolved
- env.example: document C04 RLS roles and S3 storage backend
- .gitignore: ignore instance/ and *.cutover-draft (production secrets)
2026-07-16 18:49:56 +03:00
Andrey dd849fa2d4 ✨ feat(platform): isolate runtime surfaces 2026-07-14 22:23:15 +03:00
Andrey e13542fc45 fix(ci): harden release and deployment workflow 2026-07-14 12:19:38 +03:00