服务重启后应用日志里数据库连接突然报 password authentication failed,附加信息是 Role \”postgres\” does not exist。代码和配置都没动,问题往往出在容器数据目录被复用、初始化流程被跳过上。
问题现象
一套 FastAPI 加 SQLAlchemy 加 Redis Stream 的服务,outbox 轮询原本正常工作。docker compose down 再 up 之后,应用日志出现:
auth-service | BEGIN (implicit)
auth-service | SELECT outbox_messages.id, outbox_messages.aggregate_type, …
auth-service | FROM outbox_messages
auth-service | WHERE outbox_messages.processed = false
auth-service | LIMIT $1::INTEGER FOR UPDATE SKIP LOCKED
auth-service | COMMIT
auth-postgres | FATAL: password authentication failed for user \”postgres\”
auth-postgres | DETAIL: Role \”postgres\” does not exist.
auth-postgres | Connection matched f



实现100%通过率-171主机测评](https://www.171host.com/wp-content/uploads/2026/10/20261026191216-6adfa61015a7f-220x80.gif)

