fix: retry transient database startup errors

This commit is contained in:
ice breaker
2026-08-31 16:25:13 +08:00
parent 85b593fd2f
commit 863667ce67
5 changed files with 236 additions and 5 deletions
+14
View File
@@ -49,6 +49,20 @@ volumes:
redis_data:
```
## Startup and Database Recovery
Sub2API runs database migrations while starting. PostgreSQL may still be
recovering briefly after a host or Docker daemon restart. The application
retries transient PostgreSQL startup and connection errors with bounded
exponential backoff, then continues startup when the database is ready.
Permanent errors such as invalid credentials, migration checksum mismatches,
SQL errors, and incompatible data fail immediately.
The Compose deployment also checks PostgreSQL readiness with both `pg_isready`
and a simple SQL query. `depends_on: condition: service_healthy` helps order a
fresh Compose start, but application-level retries are still required when
Docker restores existing containers after a host restart.
## Environment Variables
| Variable | Description | Required | Default |