pgpool2.git / summary / log / commit / refs

commit    2c8deed716a18e8fa7880d98874eebe0b0bce2b2
Author:   Tatsuo Ishii <ishii@postgresql.org>
Commit:   Muhammad Usama <m.usama@gmail.com>
Date:     Tue Jan 14 23:14:30 2014 +0000

    Fix primary node detection logic.
    
    There's a possibility that primary node is not detected. This happens
    in following situation.  node 0: primary, node 1: standby. Node 0 goes
    down. Health checking detects the fact but local status is not updated
    yet. Primary node finding (find_primary_node) runs. Node 0's status is
    yet healthy. Because find_primary_node fails to connect to node 0, it
    immediately returns -1 and fails to find that fact that node 1 is now
    primary.
    
    Fix is just continuing to look for primary node when fails to connect
    to a node.
    
    Per [pgpool-general: 2409].


src/main/pgpool_main.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/pgpool_main.c b/src/main/pgpool_main.c index c89f72c42..c289f85b7 100644 --- a/src/main/pgpool_main.c +++ b/src/main/pgpool_main.c @@ -2044,7 +2044,14 @@ static int find_primary_node(void) if (!s) { pool_error("find_primary_node: make_persistent_connection failed"); - return -1; + + /* + * It is possible that a node is down even if + * VALID_BACKEND tells it's valid. This could happen + * before health checking detects the failure. + * Thus we should continue to look for primary node. + */ + continue; } con = s->con; status = do_query(con, "SELECT pg_is_in_recovery()", [parent: f5f93712edac]