pgpool2.git / summary / log / commit / refs
commit ff3c54eb884b8fbb063a4501ed548112d76cc205
Author: Tatsuo Ishii <ishii@sraoss.co.jp>
Date: Fri May 03 00:02:29 2019 +0000
Speed up failover when all of backends are down.
Pgpool-II tries to find primary node till search_primary_node_timeout
expires even if all of the backend are in down status. This is not
only a waste of time but makes Pgpool-II looked like hanged because
while searching primary node failover process is suspended and all of
the Pgpool-II child process are in defunct state, thus there's no
process which accepts connection requests from clients. Since the
default value of searching primary is 300 seconds, typically this
keeps on for 300 seconds. This is not comfortable for users.
So immediately give up finding primary node regardless
search_primary_node_timeout and promptly finish the failover process
if all of the backend are in down status.
Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2019-May/003321.html
src/main/pgpool_main.c | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/src/main/pgpool_main.c b/src/main/pgpool_main.c
index 6cee6e6b5..08d935533 100644
--- a/src/main/pgpool_main.c
+++ b/src/main/pgpool_main.c
@@ -3465,6 +3465,7 @@ find_primary_node_repeatedly(void)
{
int sec;
int node_id = -1;
+ int i;
/* Streaming replication mode? */
if (!SL_MODE)
@@ -3474,7 +3475,23 @@ find_primary_node_repeatedly(void)
* mode.
*/
ereport(DEBUG1,
- (errmsg("find_primary_node: not in streaming replication mode")));
+ (errmsg("find_primary_node_repeatedly: not in streaming replication mode")));
+ return -1;
+ }
+
+ /*
+ * If all of the backends are down, there's no point to keep on searching
+ * primary node.
+ */
+ for (i = 0; i < NUM_BACKENDS; i++)
+ {
+ if (VALID_BACKEND(i))
+ break;
+ }
+ if (i == NUM_BACKENDS)
+ {
+ ereport(LOG,
+ (errmsg("find_primary_node_repeatedly: all of the backends are down. Giving up finding primary node")));
return -1;
}
[parent: 23fb4c1250f0]