[pgpool-general-jp: 722] Re: エラー発生後pool_process_query: kind is 0!

Tatsuo Ishii ishii @ sraoss.co.jp
2010年 2月 11日 (木) 18:47:42 JST


石井です。

修正版を pgpool-II 2.3.2.1として緊急リリースしました。
ダウンロードはこちらからどうぞ。
http://pgfoundry.org/frs/download.php/2566/pgpool-II-2.3.2.1.tar.gz
--
Tatsuo Ishii
SRA OSS, Inc. Japan
English: http://www.sraoss.co.jp/index_en.php
Japanese: http://www.sraoss.co.jp

> 石田さん
> 
> 石井です。レポートとパッチありがとうございます。うーん、手元の環境
> (Vine Linux 4.2)では現象が起きないので、全然気が付きませんでした。これ
> から検証して修正をコミットします。
> # もしかしたら、gccのバージョンによっては、staticメモリの配置が異なる
> # か何かで、現象が起きないのかも。ちなみに、Vineのは3.3.6です。
> --
> Tatsuo Ishii
> SRA OSS, Inc. Japan
> English: http://www.sraoss.co.jp/index_en.php
> Japanese: http://www.sraoss.co.jp
> 
> > こんにちは。石田です。
> > 
> > エラーとなるSQLを実行すると、「pool_process_query: kind is 0!」
> > とログを出力し、子プロセスが終了してしまいます。
> > 
> > pool_test=# aaa;
> > server closed the connection unexpectedly
> >         This probably means the server terminated abnormally
> >         before or while processing the request.
> > The connection to the server was lost. Attempting reset: Succeeded.
> > 
> > 2010-02-10 12:55:36 LOG:   pid 41240: SimpleQuery: Error or notice
> > message from backend: : DB node id: 0 backend pid: 41244 statement:
> > aaa; message: syntax error at or near "aaa"
> > 2010-02-10 12:55:36 DEBUG: pid 41240: wait_for_query_response: waiting
> > for backend 1 completing the query
> > 2010-02-10 12:55:36 LOG:   pid 41240: SimpleQuery: Error or notice
> > message from backend: : DB node id: 1 backend pid: 41245 statement:
> > aaa; message: syntax error at or near "aaa"
> > 2010-02-10 12:55:36 DEBUG: pid 41240: read_kind_from_backend: read
> > kind from 0 th backend ^@ NUM_BACKENDS: 2
> > 2010-02-10 12:55:36 DEBUG: pid 41240: read_kind_from_backend: read
> > kind from 1 th backend ^@ NUM_BACKENDS: 2
> > 2010-02-10 12:55:36 ERROR: pid 41240: pool_process_query: kind is 0!
> > 2010-02-10 12:55:36 LOG:   pid 41240: do_child: exits with status 1 due to error
> > 2010-02-10 12:55:36 DEBUG: pid 41241: I am 41241 accept fd 5
> > 2010-02-10 12:55:36 DEBUG: pid 41238: reap_handler called
> > 
> > gdbで追ってみたところ、pool_extract_error_messageの
> > message_buf[sizeof(message_buf)] = '\0';
> > が、実は static char buf[8192]; の先頭を書き換えてしまって
> > いたため、pool_unread()した後にkindを見ると0になって
> > しまっているようです。
> > 
> > 以下の修正でよさそうですが、文字列だけであれば
> > strlcpy()でも良いと思います。
> > 
> > diff --git a/pool_process_query.c b/pool_process_query.c
> > index 41a4f31..0ade595 100644
> > --- a/pool_process_query.c
> > +++ b/pool_process_query.c
> > @@ -4458,9 +4458,9 @@ int pool_extract_error_message(bool read_kind, POOL_CONNEC
> >             if (*e == 'M')
> >             {
> >                 e++;
> > -               len = Max(sizeof(message_buf)-1, strlen(e));
> > +               len = Min(sizeof(message_buf)-1, strlen(e));
> >                 memcpy(message_buf, e, len);
> > -               message_buf[sizeof(message_buf)] = '\0';
> > +               message_buf[len] = '\0';
> >                 break;
> >             }
> >             else
> > @@ -4471,7 +4471,7 @@ int pool_extract_error_message(bool read_kind, POOL_CONNEC
> >     else
> >     {
> >         str = pool_read_string(backend, &len, 0);
> > -       len = Max(sizeof(message_buf)-1, len);
> > +       len = Min(sizeof(message_buf)-1, len);
> >         readlen += len;
> > 
> >         if (readlen >= sizeof(buf))
> > @@ -4482,7 +4482,7 @@ int pool_extract_error_message(bool read_kind, POOL_CONNEC
> > 
> >         memcpy(p, str, len);
> >         memcpy(message_buf, str, len);
> > -       message_buf[sizeof(message_buf)] = '\0';
> > +       message_buf[len] = '\0';
> >     }
> > 
> >     if (unread)
> > 
> > 
> > 
> > -- 
> > ISHIDA Akio <iakio @ mono-space.net/ishida @ cycleof5th.com>
> > _______________________________________________
> > pgpool-general-jp mailing list
> > pgpool-general-jp @ sraoss.jp
> > http://www.sraoss.jp/mailman/listinfo/pgpool-general-jp
> _______________________________________________
> pgpool-general-jp mailing list
> pgpool-general-jp @ sraoss.jp
> http://www.sraoss.jp/mailman/listinfo/pgpool-general-jp


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