起動直後に データベースに接続できません というエラーが表示されないように#629
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 243eb4e83f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let mut guard = state.pool.write().await; | ||
| if let Some(pool) = guard.clone() { | ||
| return Some(pool); | ||
| } | ||
|
|
||
| match db::init_db().await { |
There was a problem hiding this comment.
Avoid awaiting DB init while holding write lock
Calling db::init_db().await while the RwLock write guard is held serializes all readers/writers behind a potentially long network/migration operation. When PostgreSQL is down or slow, every concurrent request that calls ensure_pool will block until the connect attempt times out, so clients wait instead of getting an immediate 503. This regression is introduced by moving connection logic into the request path and should be fixed by dropping the lock before awaiting and only reacquiring it to store the pool.
Useful? React with 👍 / 👎.
No description provided.