pgpool2.git / summary / log / commit / refs

commit    f8cb29a003fc3b896d624dfceba9722687908631
Author:   Yugo Nagata <nagata@sraoss.co.jp>
Commit:   Muhammad Usama <m.usama@gmail.com>
Date:     Wed Dec 18 06:37:41 2013 +0000

    Fix bug that restarted pgpool's watchdog status is regarded as down
    
    This is caused by improper initialization of heartbeat arrival time
    of other pgpool at accepting the add request.


src/watchdog/wd_heartbeat.c | 4 ++++ src/watchdog/wd_lifecheck.c | 8 ++++++++ src/watchdog/wd_list.c | 22 ++++++++++++++++++++-- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/watchdog/wd_heartbeat.c b/src/watchdog/wd_heartbeat.c index 59d8c5559..fe4280e35 100644 --- a/src/watchdog/wd_heartbeat.c +++ b/src/watchdog/wd_heartbeat.c @@ -410,6 +410,10 @@ wd_hb_receiver(int fork_wait_time, WdHbIf *hb_if) p->hb_send_time = pkt.send_time; p->hb_last_recv_time = tv; } + else + { + pool_debug("wd_hb_receiver: received heartbeat signal is older than the latest, ignored"); + } break; } p++; diff --git a/src/watchdog/wd_lifecheck.c b/src/watchdog/wd_lifecheck.c index f05ef3bc1..0a8ea5880 100644 --- a/src/watchdog/wd_lifecheck.c +++ b/src/watchdog/wd_lifecheck.c @@ -441,6 +441,14 @@ 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); diff --git a/src/watchdog/wd_list.c b/src/watchdog/wd_list.c index 54064af19..9ba4349eb 100644 --- a/src/watchdog/wd_list.c +++ b/src/watchdog/wd_list.c @@ -31,6 +31,8 @@ #include "watchdog/watchdog.h" #include "watchdog/wd_ext.h" +static void wd_reset_wd_info(WdInfo *info); + /* add or modify watchdog information list */ int wd_set_wd_list(char * hostname, int pgpool_port, int wd_port, char * delegate_ip, struct timeval * tv, int status) @@ -61,6 +63,11 @@ wd_set_wd_list(char * hostname, int pgpool_port, int wd_port, char * delegate_ip (p->pgpool_port == pgpool_port) && (p->wd_port == wd_port)) { + if (p->status == WD_DOWN || p->status == WD_INIT) + { + wd_reset_wd_info(p); + } + p->status = status; if (tv != NULL) @@ -75,11 +82,11 @@ wd_set_wd_list(char * hostname, int pgpool_port, int wd_port, char * delegate_ip /* not found; add as a new pgpool */ else { + wd_reset_wd_info(p); + p->status = status; p->pgpool_port = pgpool_port; p->wd_port = wd_port; - p->in_interlocking = false; - p->is_lock_holder = false; strlcpy(p->hostname, hostname, sizeof(p->hostname)); strlcpy(p->delegate_ip, delegate_ip, sizeof(p->delegate_ip)); @@ -97,6 +104,17 @@ wd_set_wd_list(char * hostname, int pgpool_port, int wd_port, char * delegate_ip return -1; } +/** reset watchdog info*/ +static void +wd_reset_wd_info(WdInfo * info) +{ + WD_TIME_INIT(info->hb_send_time); + WD_TIME_INIT(info->hb_last_recv_time); + + info->in_interlocking = false; + info->is_lock_holder = false; +} + /* add watchdog information to list using config description */ int wd_add_wd_list(WdDesc * other_wd) [parent: 6da130cf2bd4]