[pgsql-jp: 38900] Re: 大量のデータの登録時に、メモリ不足エラー
Hiroki Kataoka
kataoka @ interwiz.jp
2007年 10月 26日 (金) 20:55:28 JST
片岡です。
おそらく単なる取り込み(COPY文の実行)ではないのだろうと予想していまし
たが、やはりそうですか。
PostgreSQLでは、演算や関数処理中で使ったワークメモリの一部を、各レコー
ドの処理後ではなく、トランザクションの終了時にまとめて開放することがあり
ます(昔は文字列操作関数などでこの傾向が顕著でした)。よって、1トランザ
クションで大量のレコードを処理する場合にOut of Memoryに遭遇しやすくなり
ます。
よって、バグといえばバグかもしれませんが、仕様ともいえます。判断は微妙
なところです。
とりあえずの対策としては、演算をシンプルにするか、一度に処理する行数を
減らしていただく必要があります。どの処理(演算、関数呼び出し)がメモリを
必要以上に消費しているのかを突き止められれば、次のバージョンで改善される
可能性が高いですので、ぜひ突き止めていただきたいです(たとえば「xxx関
数の呼び出しをやめたらエラーがなくなった」など)。あるいは、処理内容を公
開していただくか。
笹倉 雅和 さんは書きました:
> 笹倉です。
>
>
>>> 約13万件のデータの取込みを行うと、53200:out_of_memory(メモリ不足)
>>> が発生してしまします。
>> 「取込み」は、具体的に何を行っていますか?
>> データは、サーバとクライアントの、どちらからどちらへ流れますか?
>> また、エラーはサーバログに出力されていますか?
>> それとも、クライアント・アプリケーション側ですか?
> データの取込みと書いたのですが、正確に書きますと、
> 問題になっているトランザクションでは、
> テーブルAに登録されているデータを元に、テーブルBに追加、または更新を
> 行い、テーブルAの処理済みレコードのフラグ操作(更新)を行っています。
> エラーは、UPDATEを実行した時の結果としてかえってきていて、
> サーバーのログ(PostgreSQL\8.2\data\pg_log)に残っています。
> (ご指摘を頂いてから、ログを見てみたのですが、エラーの記録されている
> 前後のログは、下記のようになっています。)
>
> 2007-10-25 15:52:39 ERROR: out of memory
> 2007-10-25 15:52:39 DETAIL: Failed on request of size 720400.
> 2007-10-25 15:52:39 PANIC: ERRORDATA_STACK_SIZE exceeded
>
> This application has requested the Runtime to terminate it in an unusual way.
> Please contact the application's support team for more information.
> 2007-10-25 15:52:39 LOG: server process (PID 2408) exited with exit code 3
> 2007-10-25 15:52:39 LOG: terminating any other active server processes
> 2007-10-25 15:52:39 LOG: all server processes terminated; reinitializing
> 2007-10-25 15:52:39 LOG: database system was interrupted at 2007-10-25 15:51:36 JST
> 2007-10-25 15:52:39 LOG: checkpoint record is at 1/64027DE0
> 2007-10-25 15:52:39 LOG: redo record is at 1/640080F8; undo record is at 0/0; shutdown FALSE
> 2007-10-25 15:52:39 LOG: next transaction ID: 0/2421640; next OID: 1411696
> 2007-10-25 15:52:39 LOG: next MultiXactId: 1; next MultiXactOffset: 0
> 2007-10-25 15:52:39 LOG: database system was not properly shut down; automatic recovery in progress
> 2007-10-25 15:52:39 LOG: redo starts at 1/640080F8
> 2007-10-25 15:52:39 LOG: unexpected pageaddr 1/5D97E000 in log file 1, segment 100, offset 9953280
> 2007-10-25 15:52:39 LOG: redo done at 1/6497DEC8
> 2007-10-25 15:52:40 LOG: database system is ready
> 2007-10-25 16:43:40 LOG: checkpoints are occurring too frequently (6 seconds apart)
> 2007-10-25 16:43:40 HINT: Consider increasing the configuration parameter "checkpoint_segments".
> 2007-10-25 16:43:42 WARNING: there is no transaction in progress
> 2007-10-25 16:45:33 LOG: checkpoints are occurring too frequently (29 seconds apart)
> 2007-10-25 16:45:33 HINT: Consider increasing the configuration parameter "checkpoint_segments".
> 2007-10-25 16:45:57 LOG: checkpoints are occurring too frequently (24 seconds apart)
> 2007-10-25 16:45:57 HINT: Consider increasing the configuration parameter "checkpoint_segments".
> 2007-10-25 16:46:19 LOG: checkpoints are occurring too frequently (22 seconds apart)
> 2007-10-25 16:46:19 HINT: Consider increasing the configuration parameter "checkpoint_segments".
>
>
>
> このログを見てみると、スタックが不足しているという事なのでしょうか?
>
>
> TU/笹倉
>
--
Hiroki Kataoka <kataoka @ interwiz.jp>
pgsql-jp メーリングリストの案内