doing failover.
memset(Req_info->node_id, -1, sizeof(int) * MAX_NUM_BACKENDS);
Req_info->master_node_id = get_next_master_node();
Req_info->conn_counter = 0;
+ Req_info->switching = false;
InRecovery = pool_shared_memory_create(sizeof(int));
if (InRecovery == NULL)
*/
pool_debug("failover_handler: starting to select new master node");
switching = 1;
+ Req_info->switching = true;
node_id = Req_info->node_id[0];
/* failback request? */
BACKEND_INFO(node_id).backend_status, MAX_NUM_BACKENDS);
kill(pcp_pid, SIGUSR2);
switching = 0;
+ Req_info->switching = false;
return;
}
pool_semaphore_unlock(REQUEST_INFO_SEM);
kill(pcp_pid, SIGUSR2);
switching = 0;
+ Req_info->switching = false;
return;
}
}
pool_semaphore_unlock(REQUEST_INFO_SEM);
kill(pcp_pid, SIGUSR2);
switching = 0;
+ Req_info->switching = false;
return;
}
}
pool_semaphore_unlock(REQUEST_INFO_SEM);
switching = 0;
+ Req_info->switching = false;
kill(pcp_pid, SIGUSR2);
switching = 0;
+ Req_info->switching = false;
return;
}
}
}
switching = 0;
+ Req_info->switching = false;
/* kick wakeup_handler in pcp_child to notice that
* failover/failback done
set_ps_display("PCP: processing a request", false);
+ if (tos == 'C' || tos == 'd' || tos == 'D' || tos == 'j' ||
+ tos == 'J' || tos == 'O' || tos == 'T')
+ {
+ if (Req_info->switching)
+ {
+ int len;
+ int wsize;
+ char *msg;
+
+ if (Req_info->kind == NODE_UP_REQUEST)
+ msg = "FailbackInProgress";
+ else if (Req_info->kind == NODE_DOWN_REQUEST)
+ msg = "FailoverInProgress";
+ else if (Req_info->kind == PROMOTE_NODE_REQUEST)
+ msg = "PromotionInProgress";
+ else
+ msg = "OperationInProgress";
+
+ len = strlen(msg) + 1;
+ pcp_write(frontend, "e", 1);
+ wsize = htonl(sizeof(int) + len);
+ pcp_write(frontend, &wsize, sizeof(int));
+ pcp_write(frontend, msg, len);
+ }
+ }
+
switch (tos)
{
case 'R': /* authentication */
int master_node_id; /* the youngest node id which is not in down status */
int primary_node_id; /* the primary node id in streaming replication mode */
int conn_counter;
+ bool switching; /* it true, failover or failback is in progress */
} POOL_REQUEST_INFO;
/* description of row. corresponding to RowDescription message */