/* Promote a node */ static int pool_promote_node(int node_id, bool gracefully) { if (!gracefully) { promote_backend(node_id); /* send promote request */ return 0; } /* * Wait until all frontends exit */ *InRecovery = RECOVERY_PROMOTE; /* This wiil ensure that new incoming * connection requests are blocked */ if (wait_connection_closed()) { /* wait timed out */ finish_recovery(); return -1; } /* * Now all frontends have gone. Let's do failover. */ promote_backend(node_id); /* send promote request */ /* * Wait for failover completed. */ pcp_worker_wakeup_request = 0; while (!pcp_worker_wakeup_request) { struct timeval t = {1, 0}; select(0, NULL, NULL, NULL, &t); } pcp_worker_wakeup_request = 0; /* * Start to accept incoming connections and send SIGUSR2 to pgpool * parent to distribute SIGUSR2 all pgpool children. */ finish_recovery(); return 0; }
/* send node request signal */ static void wd_node_request_signal(WD_PACKET_NO packet_no, WdNodeInfo *node) { switch (packet_no) { case WD_FAILBACK_REQUEST: send_failback_request(node->node_id_set[0]); break; case WD_DEGENERATE_BACKEND: degenerate_backend_set(node->node_id_set, node->node_num); break; case WD_PROMOTE_BACKEND: promote_backend(node->node_id_set[0]); break; default: pool_error("wd_node_request_signal: unknown packet number"); break; } }