[Pgpool-general] pgpool hangs up

Tatsuo Ishii ishii at sraoss.co.jp
Mon Sep 10 15:49:07 UTC 2007


> I tried pgpool-II 1.2. It's same - hangs up after some time. If I switch  
> php to use postgres directly, after some time pgpool starts to accept  
> connections again - and php log says it drops some connections.
> 
> It seems like some php-pgpool connections just hang in the state CONNECTED  
> and pgpool can't drop them - even if I
> set the timeout parameters.
> 
> Does pgpool have the "Incoming connection timeout" parameter or something?

Currently no.

However it's not so difficult to implement it I think. Can you please
try out included conceptual patches so that I can figure out the
functionality does any good for you?

In the patches 

 				if (frontend_idle_count > 10)

the magic number 10 means php clients will be forced to disconect from
pgpool if they do not send the next query within 10 seconds. You could
tweak it if it's too aggressive.

If this works, I will add new directive to set the "timeout" interval
of course.
--
Tatsuo Ishii
SRA OSS, Inc. Japan

Index: pool_process_query.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pool_process_query.c,v
retrieving revision 1.23.2.14
diff -c -r1.23.2.14 pool_process_query.c
*** pool_process_query.c	29 Aug 2007 05:53:41 -0000	1.23.2.14
--- pool_process_query.c	10 Sep 2007 15:35:53 -0000
***************
*** 268,273 ****
--- 268,280 ----
  			struct timeval timeout;
  			int num_fds, was_error = 0;
  
+ 		    /*
+ 			 * frontend idle counter. depends on the following
+ 			 * select(2) call's time out is 1 second.
+ 			 */
+ 			int frontend_idle_count = 0;
+ 
+ 		SELECT_RETRY:
  			timeout.tv_sec = 1;
  			timeout.tv_usec = 0;
  
***************
*** 300,306 ****
  
  			pool_debug("pool_process_query: num_fds: %d", num_fds);
  
! 			fds = select(num_fds, &readmask, &writemask, &exceptmask, NULL);
  			if (fds == -1)
  			{
  				if (errno == EINTR)
--- 307,313 ----
  
  			pool_debug("pool_process_query: num_fds: %d", num_fds);
  
! 			fds = select(num_fds, &readmask, &writemask, &exceptmask, &timeout);
  			if (fds == -1)
  			{
  				if (errno == EINTR)
***************
*** 312,318 ****
  
  			if (fds == 0)
  			{
! 				return POOL_CONTINUE;
  			}
  
  			for (i = 0; i < NUM_BACKENDS; i++)
--- 319,329 ----
  
  			if (fds == 0)
  			{
! 				frontend_idle_count++;
! 				if (frontend_idle_count > 10)
! 					return POOL_END;
! 
! 				goto SELECT_RETRY;
  			}
  
  			for (i = 0; i < NUM_BACKENDS; i++)


More information about the Pgpool-general mailing list