[Pgpool-general] pg_terminate_backend triggers failover on pgpool when used as standalone pool

Tatsuo Ishii ishii at sraoss.co.jp
Wed May 12 13:08:31 UTC 2010


> My conf file is as follows (I've removed comments etc for clarity)
[snip]

It seems the problem occurs when there's only one DB node.

1) it tries to failover to non existing node

2) it makes the node into down status which might not what you want.

#1 is purely a bug. I fix this and for #2 I'm leaning to change
existing behavior.

- In row mode and if there's only one DB node, if a problem occurs
  with the DB node, it will be brought to down status. However if the
  DB node goes into good condition again, you can use the DB node
  without restarting pgpool.

- In other mode the behavior is not changed.

Including is the patch for this. Please try.

BTW, I don't like pg_terminate_backend() causes pgpool-II a
failover. But there seems no way to improve this at this point since
message from backend is identical to the one when postmaster goes
down(in this case it's surely needed to do a failover).
--
Tatsuo Ishii
SRA OSS, Inc. Japan
English: http://www.sraoss.co.jp/index_en.php
Japanese: http://www.sraoss.co.jp
-------------- next part --------------
Index: main.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/main.c,v
retrieving revision 1.66
diff -c -r1.66 main.c
*** main.c	12 May 2010 04:58:13 -0000	1.66
--- main.c	12 May 2010 12:56:52 -0000
***************
*** 1225,1235 ****
  }
  
  /*
!  * calculate next master node id
   */
  static int get_next_master_node(void)
  {
  	int i;
  	for (i=0;i<pool_config->backend_desc->num_backends;i++)
  	{
  		/*
--- 1225,1237 ----
  }
  
  /*
!  * Calculate next valid master node id.
!  * If no valid node found, returns -1.
   */
  static int get_next_master_node(void)
  {
  	int i;
+ 
  	for (i=0;i<pool_config->backend_desc->num_backends;i++)
  	{
  		/*
***************
*** 1240,1251 ****
--- 1242,1258 ----
  		 */
  		if (RAW_MODE)
  		{
+ 			/* if in raw mode, we can switch to a standby node */
  			if (BACKEND_INFO(i).backend_status == CON_CONNECT_WAIT)
  				break;
  		}
  		else if (VALID_BACKEND(i))
  			break;
  	}
+ 
+ 	if (i == pool_config->backend_desc->num_backends)
+ 		i = -1;
+ 
  	return i;
  }
  
***************
*** 1379,1385 ****
  
  	new_master = get_next_master_node();
  
! 	if (new_master == pool_config->backend_desc->num_backends)
  	{
  		pool_error("failover_handler: no valid DB node found");
  	}
--- 1386,1392 ----
  
  	new_master = get_next_master_node();
  
! 	if (new_master < 0)
  	{
  		pool_error("failover_handler: no valid DB node found");
  	}
***************
*** 1449,1456 ****
  			trigger_failover_command(i, pool_config->failover_command);
  	}
  
! 	pool_log("failover_handler: set new master node: %d", new_master);
! 	Req_info->master_node_id = new_master;
  
  /* no need to wait since it will be done in reap_handler */
  #ifdef NOT_USED
--- 1456,1466 ----
  			trigger_failover_command(i, pool_config->failover_command);
  	}
  
! 	if (new_master >= 0)
! 	{
! 		pool_log("failover_handler: set new master node: %d", new_master);
! 		Req_info->master_node_id = new_master;
! 	}
  
  /* no need to wait since it will be done in reap_handler */
  #ifdef NOT_USED


More information about the Pgpool-general mailing list