Fix L2 deployment: healthcheck, DB deadlock, CI image resolution
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 4m37s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 4m37s
- Add /health endpoint (returns 200, skips auth middleware) - Healthcheck now hits /health instead of / (which 302s to OAuth) - Advisory lock in db.init_pool() prevents deadlock when 4 uvicorn workers race to run schema DDL - CI: --resolve-image always on docker stack deploy to force re-pull Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
11
l2/db.py
11
l2/db.py
@@ -187,9 +187,16 @@ async def init_pool():
|
||||
max_size=10,
|
||||
command_timeout=60
|
||||
)
|
||||
# Create tables if they don't exist
|
||||
# Create tables if they don't exist (advisory lock prevents deadlock
|
||||
# when multiple uvicorn workers start simultaneously)
|
||||
async with _pool.acquire() as conn:
|
||||
await conn.execute(SCHEMA)
|
||||
acquired = await conn.fetchval("SELECT pg_try_advisory_lock(42)")
|
||||
if acquired:
|
||||
try:
|
||||
await conn.execute(SCHEMA)
|
||||
finally:
|
||||
await conn.execute("SELECT pg_advisory_unlock(42)")
|
||||
# If another worker holds the lock, schema is being created — skip
|
||||
|
||||
|
||||
async def close_pool():
|
||||
|
||||
Reference in New Issue
Block a user