Skip to content

Commit

Permalink
director: Don't re-send SYNC unnecessarily often.
Browse files Browse the repository at this point in the history
  • Loading branch information
sirainen committed Mar 29, 2016
1 parent d592ce4 commit c5274b7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/director/director-connection.c
Expand Up @@ -1444,7 +1444,14 @@ static bool director_connection_sync(struct director_connection *conn,
return TRUE;
}

/* If directors got disconnected while we were waiting a SYNC reply,
it might have gotten lost. If we've received a DIRECTOR update since
the last time we sent a SYNC, retry sending it here to make sure
it doesn't get stuck. We don't want to do this too eagerly because
it may trigger desynced_hosts_hash != hosts_hash mismatch, which
causes unnecessary error logging and hosts-resending. */
if ((host == NULL || !host->self) &&
dir->last_sync_sent_ring_change_counter != dir->ring_change_counter &&
(time_t)dir->self_host->last_sync_timestamp != ioloop_time)
(void)director_resend_sync(dir);
return TRUE;
Expand Down
4 changes: 4 additions & 0 deletions src/director/director.c
Expand Up @@ -325,6 +325,9 @@ void director_sync_send(struct director *dir, struct director_host *host,
{
string_t *str;

if (host == dir->self_host)
dir->last_sync_sent_ring_change_counter = dir->ring_change_counter;

str = t_str_new(128);
str_printfa(str, "SYNC\t%s\t%u\t%u",
net_ip2addr(&host->ip), host->port, seq);
Expand Down Expand Up @@ -450,6 +453,7 @@ void director_notify_ring_added(struct director_host *added_host,
{
const char *cmd;

added_host->dir->ring_change_counter++;
cmd = t_strdup_printf("DIRECTOR\t%s\t%u\n",
net_ip2addr(&added_host->ip), added_host->port);
director_update_send(added_host->dir, src, cmd);
Expand Down
2 changes: 2 additions & 0 deletions src/director/director.h
Expand Up @@ -77,6 +77,8 @@ struct director {

struct ipc_client *ipc_proxy;
unsigned int sync_seq;
unsigned int ring_change_counter;
unsigned int last_sync_sent_ring_change_counter;
/* the lowest minor version supported by the ring */
unsigned int ring_min_version;
time_t ring_last_sync_time;
Expand Down

0 comments on commit c5274b7

Please sign in to comment.