pgpool2.git / summary / log / commit / refs

commit    5bce300c491f44d44551f8812dc79d1166bf45ff
Author:   Muhammad Usama <m.usama@gmail.com>
Date:     Fri Jul 29 13:27:43 2016 +0000

    Fixing a coding mistake in watchdog code.
    
    wd_issue_failover_lock_command() function is supposed to forward command type
    passed in as an argument to the wd_send_failover_sync_command() function instead
    it was passing the NODE_FAILBACK_CMD command type.
    The mistake was caught by uehara
    
    The commit also contains some log message enhancements


src/main/pgpool_main.c | 2 +- src/watchdog/watchdog.c | 84 +++++++++++++++++++++++++++++++++------------- src/watchdog/wd_commands.c | 2 +- 3 files changed, 63 insertions(+), 25 deletions(-) diff --git a/src/main/pgpool_main.c b/src/main/pgpool_main.c index 039d4bcda..edaf3192f 100644 --- a/src/main/pgpool_main.c +++ b/src/main/pgpool_main.c @@ -1705,7 +1705,7 @@ static void failover(void) request_details & REQ_DETAIL_SWITCHOVER && node_id != PRIMARY_NODE_ID) { ereport(LOG, - (errmsg("Do not restart children because we are switching over node id %d host%s port:%d and we are in streaming replication mode", node_id, + (errmsg("Do not restart children because we are switching over node id %d host: %s port: %d and we are in streaming replication mode", node_id, BACKEND_INFO(node_id).backend_hostname, BACKEND_INFO(node_id).backend_port))); diff --git a/src/watchdog/watchdog.c b/src/watchdog/watchdog.c index fab8630f8..02a8f4a31 100644 --- a/src/watchdog/watchdog.c +++ b/src/watchdog/watchdog.c @@ -130,6 +130,13 @@ packet_types all_packet_types[] = { {WD_NO_MESSAGE,""} }; +char* wd_failover_cmd_type_name[] = +{ + "FAILOVER", + "FAILBACK", + "PROMOTE" +}; + char *wd_event_name[] = { "STATE CHANGED", "TIMEOUT", @@ -2011,10 +2018,13 @@ node_is_asking_for_failover_cmd_start(WatchdogNode* wdNode, WDPacketData* pkt, i { WDFailoverCMDResults res = FAILOVER_RES_TRANSITION; /* only coordinator(master) node can process this request */ + ereport(LOG, - (errmsg("watchdog node \"%s\" is requesting to %s lock for failover command start", - wdNode->nodeName, - check?"check":"aquire"))); + (errmsg("%s pgpool-II node \"%s\" is %s [%s] lock to start the failover command", + (g_cluster.localNode == wdNode)? "local":"remote", + wdNode->nodeName, + check?"checking the availability of":"requesting to acquire", + wd_failover_cmd_type_name[failoverCmdType]))); if (get_local_node_state() == WD_COORDINATOR) { @@ -2029,24 +2039,32 @@ node_is_asking_for_failover_cmd_start(WatchdogNode* wdNode, WDPacketData* pkt, i /* check if we already have no lockholder node */ if (lockingNode->lockHolderNode == NULL || lockingNode->lockHolderNode == wdNode) { - ereport(LOG, - (errmsg("watchdog node \"%s\" is requesting to %s lock for failover command start", - wdNode->nodeName, - check?"check":"aquire"))); if (check == false) { lockingNode->lockHolderNode = wdNode; lockingNode->locked = true; } res = FAILOVER_RES_I_AM_LOCK_HOLDER; + ereport(LOG, + (errmsg("%s pgpool-II node \"%s\" %s [%s] lock to start the failover command", + (g_cluster.localNode == wdNode)? "local":"remote", + wdNode->nodeName, + check?"can acquire":"has", + wd_failover_cmd_type_name[failoverCmdType]))); + } else /* some other node is holding the lock */ { ereport(LOG, - (errmsg("%s lock for failover command start request is denied to node \"%s\"", - check?"check":"aquire", + (errmsg("[%s] lock %s %s pgpool-II node \"%s\" to start the failover command", + wd_failover_cmd_type_name[failoverCmdType], + check?"is not available for":"request denied to", + (g_cluster.localNode == wdNode)? "local":"remote", wdNode->nodeName), - errdetail("node \"%s\" is holding the lock",lockingNode->lockHolderNode->nodeName))); + errdetail("%s pgpool-II node \"%s\" is holding the lock", + (g_cluster.localNode == lockingNode->lockHolderNode)? "local":"remote", + lockingNode->lockHolderNode->nodeName))); + if (lockingNode->locked) res = FAILOVER_RES_BLOCKED; else @@ -2057,9 +2075,11 @@ node_is_asking_for_failover_cmd_start(WatchdogNode* wdNode, WDPacketData* pkt, i else { ereport(LOG, - (errmsg("failed to process failover command start request by watchdog node \"%s\"", - check?"check":"aquire"), - errdetail("I am standby node and request can only be handled by master node"))); + (errmsg("failed to process [%s] lock request from %s pgpool-II node \"%s\" to start the failover command", + wd_failover_cmd_type_name[failoverCmdType], + (g_cluster.localNode == wdNode)? "local":"remote", + wdNode->nodeName), + errdetail("I am standby node and request can only be processed by master watchdog node"))); res = FAILOVER_RES_ERROR; } return res; @@ -2070,10 +2090,13 @@ node_is_asking_for_failover_cmd_end(WatchdogNode* wdNode, WDPacketData* pkt, int { WDFailoverCMDResults res = FAILOVER_RES_TRANSITION; /* only coordinator(master) node can process this request */ + ereport(LOG, - (errmsg("watchdog node \"%s\" is requesting to %s lock for failover command start", + (errmsg("%s pgpool-II node \"%s\" is %s to release [%s] lock to end the failover command", + (g_cluster.localNode == wdNode)? "local":"remote", wdNode->nodeName, - resign?"check":"release"))); + resign?"requesting":"testing", + wd_failover_cmd_type_name[failoverCmdType]))); if (get_local_node_state() == WD_COORDINATOR) { @@ -2090,18 +2113,31 @@ node_is_asking_for_failover_cmd_end(WatchdogNode* wdNode, WDPacketData* pkt, int if (lockingNode->lockHolderNode == NULL || lockingNode->lockHolderNode == wdNode) { if (resign) + { lockingNode->lockHolderNode = NULL; - lockingNode->locked = false; + lockingNode->locked = false; + } res = FAILOVER_RES_LOCK_UNLOCKED; + + ereport(LOG, + (errmsg("%s pgpool-II node \"%s\" %s the [%s] lock to end the failover command", + (g_cluster.localNode == wdNode)? "local":"remote", + wdNode->nodeName, + resign?"has released":"can release", + wd_failover_cmd_type_name[failoverCmdType]))); + } else /* some other node is holding the lock */ { ereport(LOG, - (errmsg("%s lock for failover command end request is denied to node \"%s\"", - resign?"check":"release", + (errmsg("[%s] lock %s %s pgpool-II node \"%s\" to end the failover command", + wd_failover_cmd_type_name[failoverCmdType], + resign?"release request denied to":"cannot be released by", + (g_cluster.localNode == wdNode)? "local":"remote", wdNode->nodeName), - errdetail("node \"%s\" is holding the lock",lockingNode->lockHolderNode->nodeName))); - + errdetail("%s pgpool-II node \"%s\" is holding the lock", + (g_cluster.localNode == lockingNode->lockHolderNode)? "local":"remote", + lockingNode->lockHolderNode->nodeName))); res = FAILOVER_RES_BLOCKED; } } @@ -2109,9 +2145,11 @@ node_is_asking_for_failover_cmd_end(WatchdogNode* wdNode, WDPacketData* pkt, int else { ereport(LOG, - (errmsg("failed to process failover command end request by watchdog node \"%s\"", - resign?"check":"release"), - errdetail("I am standby node and request can only be handled by master node"))); + (errmsg("failed to process [%s] lock request from %s pgpool-II node \"%s\" to end the failover command", + wd_failover_cmd_type_name[failoverCmdType], + (g_cluster.localNode == wdNode)? "local":"remote", + wdNode->nodeName), + errdetail("I am standby node and request can only be processed by master watchdog node"))); res = FAILOVER_RES_ERROR; } diff --git a/src/watchdog/wd_commands.c b/src/watchdog/wd_commands.c index f017aff7e..cf90aff3a 100644 --- a/src/watchdog/wd_commands.c +++ b/src/watchdog/wd_commands.c @@ -761,7 +761,7 @@ static WDFailoverCMDResults wd_issue_failover_lock_command(WDFailoverCMDTypes cm int x; for (x=0; x < MAX_SEC_WAIT_FOR_CLUSTER_TRANSATION; x++) { - res = wd_send_failover_sync_command(NODE_FAILBACK_CMD, syncReqType); + res = wd_send_failover_sync_command(cmdType, syncReqType); if (res != FAILOVER_RES_TRANSITION) break; sleep(1); [parent: 6ff2ac0a512c]