poke it around until it works less badly

This commit is contained in:
Ian Barwick
2017-06-29 09:35:09 +09:00
parent fa86fe4ad8
commit 3514e20367
7 changed files with 81 additions and 7 deletions

View File

@@ -576,7 +576,8 @@ monitor_streaming_standby(void)
}
}
// store lsndiffs, in the event we're not the best node,
// i.e. don't get all the votes, we pass the baton to the best node
static NodeVotingStatus
do_election(void)
{
@@ -598,6 +599,8 @@ do_election(void)
long unsigned rand_wait = (long) ((rand() % 50) + 10) * 10000;
bool other_node_is_candidate = false;
log_debug("do_election(): sleeping %li", rand_wait);
pg_usleep(rand_wait);
@@ -646,10 +649,21 @@ do_election(void)
continue;
}
if (announce_candidature(cell->node_info->conn, &local_node_info, cell->node_info) == false)
{
log_debug("node %i is candidate", cell->node_info->node_id);
other_node_is_candidate = true;
}
cell->node_info->is_visible = true;
visible_nodes ++;
}
if (other_node_is_candidate == true)
{
return VS_NO_VOTE;
}
// XXX check if > 50% visible
/* check again if we've been asked to vote */