[pgsql-jp: 30279] Re: ERROR: out of free buffers: time to abort !

Tatsuo Ishii t-ishii @ sra.co.jp
2003年 6月 30日 (月) 16:32:28 JST


石井です.

> ども。渡辺と申します。
> 
> PHP4.3.0, postgreSQL7.1.1 Apache1.3.27 Redhat6.2
> という構成でWebサイトを組んでおります。
> 
> 最近アクセス数が増えてきて、例によって23時ごろの高負荷
> がかなりヤバイところまできてしまいました。
> 
> 具体的には、ブラウザからの同時アクセスが増えてくると、
> 以下のようなログが出て、事実上アクセスできない
> 状態になることがあるようです。
> 
> 高負荷のときのpostgreSQLのログの例:
>   ※まともに動いている時間帯には何も出ない。
> 
> Jun 24 23:17:15 host postgres[13333]: [1-1] ERROR:  out of free buffers: time to abort !
> Jun 24 23:17:30 host postgres[13394]: [1-1] ERROR:  out of free buffers: time to abort !
> Jun 24 23:17:30 host postgres[13370]: [1-1] ERROR:  out of free buffers: time to abort !
> Jun 24 23:18:52 host postgres[13363]: [1-1] ERROR:  out of free buffers: time to abort !
> Jun 24 23:18:52 host postgres[13404]: [1-1] ERROR:  out of free buffers: time to abort !
> Jun 24 23:19:07 host postgres[13361]: [1-1] ERROR:  out of free buffers: time to abort !
> Jun 24 23:19:10 host postgres[13379]: [1-1] ERROR:  out of free buffers: time to abort !
> Jun 24 23:19:10 host postgres[13356]: [1-1] ERROR:  out of free buffers: time to abort !
> Jun 24 23:19:10 host postgres[13430]: [1-1] ERROR:  out of free buffers: time to abort !
> Jun 24 23:20:02 host postgres[13442]: [1-1] ERROR:  out of free buffers: time to abort !
> Jun 24 23:20:02 host postgres[13455]: [1-1] FATAL 1:  out of free buffers: time to abort !
> Jun 24 23:20:02 host postgres[13348]: [1-1] ERROR:  out of free buffers: time to abort !
> Jun 24 23:20:02 host postgres[13400]: [1-1] ERROR:  out of free buffers: time to abort !
> Jun 24 23:20:02 host postgres[13383]: [1-1] ERROR:  out of free buffers: time to abort !
> 
> 
> 高負荷のときのtopコマンドの例(抜粋です): 
>    ※低負荷時にはDB接続もhttpdも一つか二つずつくらいしかない。
>    ※Apacheのmaxcliantsは8に絞ってるのに
>      なんでこんなにDB接続が増えちゃうんだろ?・・・。

たぶん処理に時間がかかるんで,Apacheが途中で処理を中断したものの,
PostgreSQLのバックエンドプロセスが残ってしまっている状態なんでしょう.
下のpsの結果を見てもpostgresはみんなrun状態だし.

>   PID USER     PRI  NI  SIZE  RSS SHARE STAT  LIB %CPU %MEM   TIME COMMAND
> 13445 postgres  12   0  2888 2852  1900 R       0  7.0  4.4   0:16 postgres: user01 db01
> 13451 postgres  12   0  2888 2852  1904 R       0  7.0  4.4   0:16 postgres: user01 db01
> 13496 postgres  12   0  2924 2888  1920 R       0  6.2  4.5   0:11 postgres: user01 db01
> 13550 postgres  13   0  2468 2432  1812 R       0  6.2  3.8   0:03 postgres: user01 db01
> 13554 postgres  12   0  2832 2796  1900 R       0  6.2  4.3   0:02 postgres: user01 db01
> 13486 postgres  12   0  2928 2892  1920 R       0  5.5  4.5   0:12 postgres: user01 db01
> 13487 postgres  12   0  2908 2876  1928 R       0  5.5  4.4   0:12 postgres: user01 db01
> 13495 postgres  12   0  2920 2884  1920 R       0  5.5  4.5   0:12 postgres: user01 db01
> 13508 postgres  12   0  2868 2832  1904 R       0  5.5  4.4   0:09 postgres: user01 db01
> 13503 postgres  12   0  2916 2880  1920 R       0  4.7  4.5   0:09 postgres: user01 db01
> 13509 postgres  12   0  2872 2836  1904 R       0  4.7  4.4   0:09 postgres: user01 db01
> 13522 postgres  12   0  2892 2856  1916 R       0  4.7  4.4   0:06 postgres: user01 db01
> 13575 postgres   8   0  2472 2436  1780 R       0  4.7  3.8   0:00 postgres: user01 db01
> 13450 postgres  11   0  2964 2928  1944 R       0  3.9  4.5   0:15 postgres: user01 db01
> 13534 postgres  12   0  2892 2856  1920 R       0  3.9  4.4   0:04 postgres: user01 db01
> 13468 postgres  10   0  2880 2844  1900 R       0  3.1  4.4   0:13 postgres: user01 db01
> 13458 postgres  11   0  2888 2852  1904 R       0  2.3  4.4   0:15 postgres: user01 db01
> 13551 postgres  10   0  2492 2456  1820 R       0  2.3  3.8   0:01 postgres: user01 db01
>     4 root       3   0     0    0     0 SW      0  1.5  0.0  31:03 kswapd
> 32578 root       5   0  1012  256   212 S       0  1.5  0.4   0:05 /usr/local/apache/bin/httpd
> 13546 postgres  10   0  2764 2744  1972 R       0  1.5  4.2   0:02 postgres: user01 db01
> 13547 postgres   9   0  2764 2748  1968 D       0  1.5  4.2   0:02 postgres: user01 db01
> 32574 postgres   1   0   448  336   256 S       0  0.0  0.5   0:09 /usr/local/pgsql/bin/postmas
> 13511 nobody     0   0  1660 1024   900 S       0  0.0  1.6   0:00 /usr/local/apache/bin/httpd
> 13521 nobody     0   0  3024 2808  2036 S       0  0.0  4.3   0:00 /usr/local/apache/bin/httpd
> 13539 nobody     0   0  1876 1320  1172 S       0  0.0  2.0   0:00 /usr/local/apache/bin/httpd
> 13552 nobody     0   0  1660 1024   900 S       0  0.0  1.6   0:00 /usr/local/apache/bin/httpd
> 13564 nobody     2   0  3040 2832  2076 S       0  0.0  4.4   0:00 /usr/local/apache/bin/httpd
> 13565 nobody     0   0  1660 1024   912 S       0  0.0  1.6   0:00 /usr/local/apache/bin/httpd
> 13576 nobody     3   0  1660 1024   920 S       0  0.0  1.6   0:00 /usr/local/apache/bin/httpd
> 13577 nobody     4   0  1660 1024   920 S       0  0.0  1.6   0:00 /usr/local/apache/bin/httpd

ところで,postgresの実行時間が最大16秒くらいとかなり長いんですが,これ
ではWebシステムとしてはまともなレスポンスは期待できないと思います.イ
ンデックスは適切に設定されていますか?非常に無駄なSQLが走っているなん
てことはないですか?そういうのがあると,postgresql.confのチューニング
なんてしても焼石に水です.

> postgresql.confはほとんどデフォルトのまま
> 個人的には、postgresql.confをに何らかの適切な値をちゃんと
> 設定すべきかなとは思っているのですが、
> ちょっとno ideaです。
> 「いいチューニング方法がここに載ってるよ」
> というポインタだけでも結構ですのでアドバイス求むです。

とりあえず out of free buffers 対策のために shared_buffers を増やしま
しょう.1024位がいいかな.

後はwal_sync_method.これをopen_syncにしてみましょう.

> # 石井さんのpg_poolが真剣に欲しくなってきた・・・

是非人柱になってください:-)
--
Tatsuo Ishii



pgsql-jp メーリングリストの案内