Refactor failover().
authorTatsuo Ishii <ishii@sraoss.co.jp>
Tue, 8 Feb 2022 05:26:29 +0000 (14:26 +0900)
committerTatsuo Ishii <ishii@sraoss.co.jp>
Tue, 8 Feb 2022 05:38:12 +0000 (14:38 +0900)
commit6df397cea1f4d86ab5292a3f703b706e3c3c979e
tree5219f6ff56a7103fb64862939b00040446772df0
parent779360609c768ec8aa6e3f761c1dff9d06837220
Refactor failover().

failover() was too large and hard to maintain. By refactoring it, the
size is reduced from 798 lines to 215 lines.  It is now splitted into
following subroutines. failover() just calls them.

static int handle_failback_request(FAILOVER_CONTEXT *failover_context, int node_id);
static int handle_failover_request(FAILOVER_CONTEXT *failover_context, int node_id);
static void kill_failover_children(FAILOVER_CONTEXT *failover_context, int node_id);
static void exec_failover_command(FAILOVER_CONTEXT *failover_context, int new_main_node_id, int promote_node_id);
static int determine_new_primary_node(FAILOVER_CONTEXT *failover_context, int node_id);
static int exec_follow_primary_command(FAILOVER_CONTEXT *failover_context, int node_id, int new_primary_node_id);
static void save_node_info(FAILOVER_CONTEXT *failover_context, int new_primary_node_id, int new_main_node_id);
static void exec_child_restart(FAILOVER_CONTEXT *failover_context, int node_id);
static void exec_notice_pcp_child(FAILOVER_CONTEXT *failover_context);
src/main/pgpool_main.c