0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

DBセッション数エラー発生後の調査観点

Last updated at Posted at 2021-12-11

【事象】
・以下のエラーが発生し、サーバーの応答がなくなった。

FATAL: 53300: sorry, too many clients already

【やりたいこと】
エラー内容から憶測はつくが事後調査として、DB側で確認できるポイントはないか。

【確認方法】
・postgresql.confで今回のエラーに関係するパラメータ設定値を確認

max_connections = 100
#superuser_reserved_connections = 5

上記max_connectionsの値をコネクション数が超えていないか確認する。
※ちなみにsuperuser_reserved_connectionsは、スーパーユーザで接続用に予約されている接続の数で、一般ユーザの接続は max_connectionsからsuperuser_reserved_connections を引いた95という値になる。これは上記の現象発生の際に実行されているSQLやロックの状況などを調査するためのもの。

・PostgreSQLログファイルを確認
調査可能となる記録を残すパラメータとしては、以下がある

#log_connections = off
#log_disconnections = off

接続時と切断時が一致しているものを除き、接続時のみ残っているものを抽出すれば、障害発生時点でどこから接続されていたか分かる。また、事象発生時までの間に、何らかのエラーなり遅延があれば発生した要因の候補を下記パラメータを利用してピックアップ(一定時間以上かかったSQL文を記録する)できる。

  #log_min_duration_statement = -1 # -1 is disabled, 0 logs all statements

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?