[Pgpool-general] Is master / slave mode working ?

Tatsuo Ishii ishii at sraoss.co.jp
Sun Nov 13 00:00:12 GMT 2005


> Hi,
> 
> I have tried to use pgpool in master / slave mode, without success.
> Starting with both databases alive, when the slave database is being
> shutdown, pgpool failover from the master to the slave !
> 
> Here are the logs corresponding to that funny situation.
> The configuration is enclosed in the first lines of the log.
> 
> Am i missing something ??

Thanks for the report. Can you try with including patches to main.c?

BTW, I'm wondering what pgpool should do if master goes down. In
master/slave mode, should pgpool kill itself not to continue to accept
queries or treat the slave as if it's a new master?
--
SRA OSS, Inc. Japan
Tatsuo Ishii
-------------- next part --------------
Index: main.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool/main.c,v
retrieving revision 1.9
diff -c -r1.9 main.c
*** main.c	9 Nov 2005 14:12:21 -0000	1.9
--- main.c	12 Nov 2005 23:57:14 -0000
***************
*** 781,787 ****
  	 * if not in replication mode/master slave mode, we treat this a restart request.
  	 * otherwise we need to check if we have already failovered.
  	 */
! 	if (!pool_config.replication_enabled || !pool_config.master_slave_enabled ||
  		strcmp(pool_config.current_backend_host_name, pool_config.secondary_backend_host_name) ||
  		pool_config.current_backend_port != pool_config.secondary_backend_port)
  	{
--- 781,787 ----
  	 * if not in replication mode/master slave mode, we treat this a restart request.
  	 * otherwise we need to check if we have already failovered.
  	 */
! 	if (pool_config.replication_enabled || pool_config.master_slave_enabled ||
  		strcmp(pool_config.current_backend_host_name, pool_config.secondary_backend_host_name) ||
  		pool_config.current_backend_port != pool_config.secondary_backend_port)
  	{
***************
*** 807,812 ****
--- 807,833 ----
  				pool_config.server_status[0] = 2;		/* mark this down */
  			}
  		}
+ 
+ 		else if (pool_config.master_slave_enabled)
+ 		{
+ 			degenerated = 1;
+ 
+ 			if (sig == SIGUSR2)
+ 			{
+ 				pool_log("starting degeneration. shutdown slave host %s(%d)",
+ 						 pool_config.secondary_backend_host_name,
+ 						 pool_config.secondary_backend_port);
+ 				pool_config.server_status[1] = 2;		/* mark this down */
+ 			}
+ 			else
+ 			{
+ 				pool_log("starting degeneration. shutdown master host %s(%d)",
+ 						 pool_config.backend_host_name,
+ 						 pool_config.backend_port);
+ 				pool_config.server_status[0] = 2;		/* mark this down */
+ 			}
+ 		}
+ 
  		else if (!degenerated && pool_config.secondary_backend_port != 0)
  		{
  			pool_log("starting failover from %s(%d) to %s(%d)",
***************
*** 849,854 ****
--- 870,888 ----
  				pool_config.current_backend_port = pool_config.secondary_backend_port;
  			}
  		}
+ 
+ 		else if (pool_config.master_slave_enabled)
+ 		{
+ 			/* disable master/slave mode */
+ 			pool_config.master_slave_enabled = 0;
+ 
+ 			if (sig == SIGUSR1)
+ 			{
+ 				pool_config.current_backend_host_name = pool_config.secondary_backend_host_name;
+ 				pool_config.current_backend_port = pool_config.secondary_backend_port;
+ 			}
+ 		}
+ 
  		else if (!degenerated && pool_config.secondary_backend_port != 0)
  		{
  			/* fail over to secondary */


More information about the Pgpool-general mailing list