pgpool2.git / summary / log / commit / refs
commit 80c70caebd12961d0878f298e4c7fcbf0c07a9bd
Author: Tatsuo Ishii <ishii@postgresql.org>
Date: Mon Oct 07 01:33:36 2013 +0000
Avoid calling find_primary_node_repeatedly() when standby node goes down.
This will reduce the time to failover. Per bug #75, patch modified by
Tatsuo Ishii.
src/main/main.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/src/main/main.c b/src/main/main.c
index c72cf0df4..8e78c5079 100644
--- a/src/main/main.c
+++ b/src/main/main.c
@@ -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();
[parent: 7afd111d39c3]