[Pgpool-general] pgpool-II 2.3.x problem

Tatsuo Ishii ishii at sraoss.co.jp
Thu Feb 11 08:56:29 UTC 2010


Hi,

It is identfied that pgpool-II 2.3.x has a problem with erroneous
query processing. For example, you might see following symptom:

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.

>From pgpool log:

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

This is caused by error/notice message extraction process. So it
possible that any query involves error or notice is suffered by this
bug. Any data corrpution or data inconsistency does not happen
because of this bug.

Please note that this problem will not happen if pgpool is compiled by
older version of gcc. That's one of the reasons why I didn't notice
until today (my gcc is 3.3.6). So you may or may not see the bug
depending on the version of gcc.

I will release pgpool-II 2.3.3 soon. If you hurry, please use included
patches.
--
Tatsuo Ishii
SRA OSS, Inc. Japan
English: http://www.sraoss.co.jp/index_en.php
Japanese: http://www.sraoss.co.jp
-------------- next part --------------
Index: pool_process_query.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pool_process_query.c,v
retrieving revision 1.195
retrieving revision 1.196
diff -c -r1.195 -r1.196
*** pool_process_query.c	7 Feb 2010 07:04:59 -0000	1.195
--- pool_process_query.c	10 Feb 2010 09:41:43 -0000	1.196
***************
*** 1,6 ****
  /* -*-pgsql-c-*- */
  /*
!  * $Header: /cvsroot/pgpool/pgpool-II/pool_process_query.c,v 1.195 2010/02/07 07:04:59 t-ishii Exp $
   *
   * pgpool: a language independent connection pool server for PostgreSQL
   * written by Tatsuo Ishii
--- 1,6 ----
  /* -*-pgsql-c-*- */
  /*
!  * $Header: /cvsroot/pgpool/pgpool-II/pool_process_query.c,v 1.196 2010/02/10 09:41:43 t-ishii Exp $
   *
   * pgpool: a language independent connection pool server for PostgreSQL
   * written by Tatsuo Ishii
***************
*** 4458,4466 ****
  			if (*e == 'M')
  			{
  				e++;
! 				len = Max(sizeof(message_buf)-1, strlen(e));
! 				memcpy(message_buf, e, len);
! 				message_buf[sizeof(message_buf)] = '\0';
  				break;
  			}
  			else
--- 4458,4465 ----
  			if (*e == 'M')
  			{
  				e++;
! 				strncpy(message_buf, e, sizeof(message_buf)-1);
! 				message_buf[sizeof(message_buf)-1] = '\0';
  				break;
  			}
  			else
***************
*** 4471,4477 ****
  	else
  	{
  		str = pool_read_string(backend, &len, 0);
! 		len = Max(sizeof(message_buf)-1, len);
  		readlen += len;
  
  		if (readlen >= sizeof(buf))
--- 4470,4476 ----
  	else
  	{
  		str = pool_read_string(backend, &len, 0);
! 		len = Min(sizeof(message_buf)-1, len);
  		readlen += len;
  
  		if (readlen >= sizeof(buf))
***************
*** 4482,4488 ****
  
  		memcpy(p, str, len);
  		memcpy(message_buf, str, len);
! 		message_buf[sizeof(message_buf)] = '\0';
  	}
  
  	if (unread)
--- 4481,4487 ----
  
  		memcpy(p, str, len);
  		memcpy(message_buf, str, len);
! 		message_buf[len] = '\0';
  	}
  
  	if (unread)


More information about the Pgpool-general mailing list