[pgpool-general-jp: 386] pgpool 3.4.1のhealth checkについて

Kenichi Sawada k @ sawada.cc
2008年 2月 25日 (月) 11:31:25 JST


お世話になります。
澤田と申します。

pgpool-3.4.1をhealth checkありで使っているのですが、
「バックエンドのPostgreSQLが何らかの原因で動作しなくなったが
portはlistenしており、TCPレベルではconnectするものの、返答が一切ない」
という状況で、health checkが動作(タイムアウト)しないようです。
これはおそらくhealth_check()においてALARMシグナルがブロックされている
ためではないかと思い、添付の通りパッチを作成してみたところ
一応動作するようですが、他部分への影響など何かありますでしょうか?

また、health checkなしでも上記状況の場合に縮退させるには
どうしたらよいでしょうか?

どうぞ宜しくお願い致します。

--澤田 研一
--k @ sawada.cc
-------------- next part --------------
*** main.c	2007-08-10 12:57:44.000000000 +0900
--- main.c.new	2008-02-25 11:13:34.000000000 +0900
***************
*** 107,113 ****
  static int stop_sig = SIGTERM;	/* stopping signal default value */
  static int switch_over_sig = SIGUSR1;	/* switch over signal default value */
  
! static int health_check_timer_expired;		/* non 0 if health check timer expired */
  static volatile sig_atomic_t failover_request = 0;
  static volatile sig_atomic_t sigchld_request = 0;
  static int pipe_fds[2]; /* for delivering signals */
--- 107,113 ----
  static int stop_sig = SIGTERM;	/* stopping signal default value */
  static int switch_over_sig = SIGUSR1;	/* switch over signal default value */
  
! int health_check_timer_expired;		/* non 0 if health check timer expired */
  static volatile sig_atomic_t failover_request = 0;
  static volatile sig_atomic_t sigchld_request = 0;
  static int pipe_fds[2]; /* for delivering signals */
***************
*** 360,366 ****
  				/*
  				 * set health checker timeout. we want to detect
  				 * commnuication path failure much earlier before
! 				 * TCP/IP statck detects it.
  				 */
  				pool_signal(SIGALRM, health_check_timer_handler);
  				alarm(pool_config.health_check_timeout);
--- 360,366 ----
  				/*
  				 * set health checker timeout. we want to detect
  				 * commnuication path failure much earlier before
! 				 * TCP/IP stack detects it.
  				 */
  				pool_signal(SIGALRM, health_check_timer_handler);
  				alarm(pool_config.health_check_timeout);
***************
*** 371,377 ****
--- 371,379 ----
  			 */
  			errno = 0;
  			health_check_timer_expired = 0;
+ 			POOL_SETMASK(&UnBlockSig);
  			sts = health_check();
+ 			POOL_SETMASK(&BlockSig);
  
  			if (errno != EINTR || (errno == EINTR && health_check_timer_expired))
  			{
-------------- next part --------------
*** child.c	2007-08-01 13:25:40.000000000 +0900
--- child.c.new	2008-02-25 11:13:36.000000000 +0900
***************
*** 73,78 ****
--- 73,79 ----
  
  extern int myargc;
  extern char **myargv;
+ extern int health_check_timer_expired;
  
  char remote_ps_data[NI_MAXHOST];		/* used for set_ps_display */
  
***************
*** 1177,1182 ****
--- 1178,1190 ----
  	}
  
  	read(fd, &kind, 1);
+ 	if (health_check_timer_expired == 1) {
+ 		pool_error("health check failed during read. master %s at port %d is open but no response",
+ 				   pool_config.current_backend_host_name,
+ 				   pool_config.current_backend_port);
+ 		close(fd);
+ 		return -1;
+ 	}
  
  	if (write(fd, "X", 1) < 0)
  	{
***************
*** 1215,1220 ****
--- 1223,1235 ----
  	}
  
  	read(fd, &kind, 1);
+ 	if (health_check_timer_expired == 1) {
+ 		pool_error("health check failed during read. secondary %s at port %d is open but no response",
+ 				   pool_config.secondary_backend_host_name,
+ 				   pool_config.secondary_backend_port);
+ 		close(fd);
+ 		return -2;
+ 	}
  
  	if (write(fd, "X", 1) < 0)
  	{


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