Avoid calling find_primary_node_repeatedly() when standby node goes down.
authorTatsuo Ishii <ishii@postgresql.org>
Mon, 7 Oct 2013 01:33:36 +0000 (10:33 +0900)
committerTatsuo Ishii <ishii@postgresql.org>
Mon, 7 Oct 2013 01:33:36 +0000 (10:33 +0900)
This will reduce the time to failover. Per bug #75, patch modified by
Tatsuo Ishii.

src/main/main.c

index c72cf0df48cef02268701aa10f6176f3735431b6..8e78c50794d79dfa900364a89a3e9d627f0be268 100644 (file)
@@ -1976,6 +1976,21 @@ static void failover(void)
 
        if (Req_info->kind == PROMOTE_NODE_REQUEST && VALID_BACKEND(node_id))
                new_primary = node_id;
+
+       /*
+        * If the down node was a standby node in streaming replication
+        * mode, we can avoid calling find_primary_node_repeatedly() and
+        * recognize the former primary as the new primary node, which
+        * will reduce the time to process standby down.
+        */
+       else if (MASTER_SLAVE && !strcmp(pool_config->master_slave_sub_mode, MODE_STREAMREP) &&
+                        Req_info->kind == NODE_DOWN_REQUEST)
+       {
+               if (Req_info->primary_node_id != node_id)
+                       new_primary = Req_info->primary_node_id;
+               else
+                       new_primary =  find_primary_node_repeatedly();
+       }
        else
                new_primary =  find_primary_node_repeatedly();