pgpool2.git / summary / log / commit / refs
commit 679553699f7f8e5ba8d3e39d8000d2e6ca753d22
Author: Tatsuo Ishii <ishii@postgresql.org>
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/main.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/main/main.c b/src/main/main.c
index 553b7241b..d5c2fa026 100644
--- a/src/main/main.c
+++ b/src/main/main.c
@@ -2841,7 +2841,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: 220fabaf3a4e]