static void check_pgpool_status_by_hb(void) { int cnt; WdInfo *p = WD_List; struct timeval tv; gettimeofday(&tv, NULL); cnt = 0; while (p->status != WD_END) { ereport(DEBUG1, (errmsg("watchdog life checking by heartbeat"), errdetail("checking pgpool %d (%s:%d)", cnt, p->hostname, p->pgpool_port))); /* about myself */ if (p == WD_MYSELF) { /* parent is dead so it's orphan.... */ if (is_parent_alive() == WD_NG && WD_MYSELF->status != WD_DOWN) { ereport(LOG, (errmsg("checking pgpool status by heartbeat"), errdetail("lifecheck failed. pgpool %d (%s:%d) seems not to be working", cnt, p->hostname, p->pgpool_port))); wd_set_myself(&tv, WD_DOWN); wd_notice_server_down(); } /* otherwise, the parent would take care of children. */ else { ereport(DEBUG1, (errmsg("watchdog life checking by heartbeat"), errdetail("OK; status %d", p->status))); } } /* about other pgpools, check the latest heartbeat. */ else { if (p->status == WD_DOWN) { ereport(LOG, (errmsg("checking pgpool status by heartbeat"), errdetail("pgpool: %d at \"%s:%d\" status is down", cnt, p->hostname, p->pgpool_port))); } else if (wd_check_heartbeat(p) == WD_NG) { ereport(DEBUG1, (errmsg("checking pgpool status by heartbeat"), errdetail("NG; status %d", p->status))); ereport(LOG, (errmsg("checking pgpool status by heartbeat"), errdetail("lifecheck failed. pgpool: %d at \"%s:%d\" seems not to be working", cnt, p->hostname, p->pgpool_port))); if (p->status != WD_DOWN) pgpool_down(p); } else { ereport(DEBUG1, (errmsg("checking pgpool status by heartbeat"), errdetail("OK; status %d", p->status))); } } p++; cnt++; if (cnt >= MAX_WATCHDOG_NUM) { ereport(WARNING, (errmsg("checking pgpool status by heartbeat, pgpool num is out of range:%d",cnt))); break; } } }
static void check_pgpool_status_by_hb(void) { int cnt; WdInfo * p = WD_List; struct timeval tv; gettimeofday(&tv, NULL); cnt = 0; while (p->status != WD_END) { pool_debug("check_pgpool_status_by_hb: checking pgpool %d (%s:%d)", cnt, p->hostname, p->pgpool_port); /* about myself */ if (p == WD_MYSELF) { /* parent is dead so it's orphan.... */ if (is_parent_alive() == WD_NG && WD_MYSELF->status != WD_DOWN) { pool_debug("check_pgpool_status_by_hb: NG; the main pgpool process does't exist."); pool_log("check_pgpool_status_by_hb: lifecheck failed. pgpool %d (%s:%d) seems not to be working", cnt, p->hostname, p->pgpool_port); wd_set_myself(&tv, WD_DOWN); wd_notice_server_down(); } /* otherwise, the parent would take care of children. */ else { pool_debug("check_pgpool_status_by_hb: OK; status %d", p->status); } } /* about other pgpools, check the latest heartbeat. */ else { if (p->status == WD_DOWN) { pool_log("check_pgpool_status_by_hb: pgpool %d (%s:%d) is in down status", cnt, p->hostname, p->pgpool_port); } else if (wd_check_heartbeat(p) == WD_NG) { pool_debug("check_pgpool_status_by_hb: NG; status %d", p->status); pool_log("check_pgpool_status_by_hb: lifecheck failed. pgpool %d (%s:%d) seems not to be working", cnt, p->hostname, p->pgpool_port); if (p->status != WD_DOWN) pgpool_down(p); } else { pool_debug("check_pgpool_status_by_hb: OK; status %d", p->status); } } p++; cnt++; if (cnt >= MAX_WATCHDOG_NUM) { pool_error("check_pgpool_status_by_hb: pgpool num is out of range(%d)",cnt); break; } } }