示例#1
0
/*
 * Check if pgpool is alive using heartbeat signal.
 */
int
wd_check_heartbeat(WdInfo * pgpool)
{
	int interval;
	struct timeval tv;

	if (!WD_TIME_ISSET(pgpool->hb_last_recv_time) ||
	    !WD_TIME_ISSET(pgpool->hb_send_time))
	{
		ereport(DEBUG1,
			(errmsg("watchdog checking if pgpool is alive using heartbeat"),
				errdetail("pgpool (%s:%d) was restarted and has not send the heartbeat signal yet",
					   pgpool->hostname, pgpool->pgpool_port)));
		return WD_OK;
	}

	gettimeofday(&tv, NULL);

	interval = WD_TIME_DIFF_SEC(tv, pgpool->hb_last_recv_time);
	ereport(DEBUG1,
		(errmsg("watchdog checking if pgpool is alive using heartbeat"),
			errdetail("the last heartbeat from \"%s:%d\" received %d seconds ago",
				   pgpool->hostname, pgpool->pgpool_port, interval)));

	if (interval > pool_config->wd_heartbeat_deadtime)
		return WD_NG;
	else
		return WD_OK;
}
示例#2
0
/*
 * Check if pgpool is alive using heartbeat signal.
 */
int
wd_check_heartbeat(WdInfo * pgpool)
{
	int interval;
	struct timeval tv;

	if (!WD_TIME_ISSET(pgpool->hb_last_recv_time) ||
	    !WD_TIME_ISSET(pgpool->hb_send_time))
	{
		pool_debug("wd_check_heartbeat: pgpool (%s:%d) was restarted and has not send the heartbeat signal yet",
		           pgpool->hostname, pgpool->pgpool_port);
		return WD_OK;
	}

	gettimeofday(&tv, NULL);

	interval = WD_TIME_DIFF_SEC(tv, pgpool->hb_last_recv_time);
	pool_debug("wd_check_heartbeat: the latest heartbeat from %s:%d received %d seconds ago",
	           pgpool->hostname, pgpool->pgpool_port, interval);

	if (interval > pool_config->wd_heartbeat_deadtime)
		return WD_NG;
	else
		return WD_OK;
}