repmgrd: fixes to failover handling

get_new_primary() returns NULL if no notification for the new primary has
been received, but the code was expecting it to return UNKNOWN_NODE_ID,
which was causing repmgrd to prematurely drop out of the new primary
detection loop if no notification had been received by the time the loop
started.

Also store the electoral term as a single row, single column table,
to ensure that all repmgrds see the same turn. It is then bumped
by the winning node after it gets promoted.

Various logging improvements.
This commit is contained in:
Ian Barwick
2017-11-08 14:19:52 +09:00
parent 7232187f4d
commit 79d21b516b
5 changed files with 134 additions and 29 deletions

View File

@@ -474,9 +474,11 @@ bool delete_monitoring_records(PGconn *primary_conn, int keep_history);
/* node voting functions */
int get_current_term(PGconn *conn);
void increment_current_term(PGconn *conn);
NodeVotingStatus get_voting_status(PGconn *conn);
VoteRequestResult request_vote(PGconn *conn, t_node_info *this_node, t_node_info *other_node, int electoral_term);
int set_voting_status_initiated(PGconn *conn);
void set_voting_status_initiated(PGconn *conn, int electoral_term);
bool announce_candidature(PGconn *conn, t_node_info *this_node, t_node_info *other_node, int electoral_term);
void notify_follow_primary(PGconn *conn, int primary_node_id);
bool get_new_primary(PGconn *conn, int *primary_node_id);