Skip to content

起動直後に データベースに接続できません というエラーが表示されないように#629

Merged
narumincho merged 4 commits into
mainfrom
dev
May 11, 2026
Merged

起動直後に データベースに接続できません というエラーが表示されないように#629
narumincho merged 4 commits into
mainfrom
dev

Conversation

@narumincho

Copy link
Copy Markdown
Owner

No description provided.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread definy-server/src/main.rs Outdated
Comment on lines +167 to +172
let mut guard = state.pool.write().await;
if let Some(pool) = guard.clone() {
return Some(pool);
}

match db::init_db().await {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

@narumincho narumincho merged commit 147e96e into main May 11, 2026
1 check passed
@narumincho narumincho deleted the dev branch May 11, 2026 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant