From: Timo Sirainen Date: Thu, 24 Mar 2016 00:42:50 +0000 (+0900) Subject: director: Don't re-send SYNC unnecessarily often. X-Git-Tag: 2.2.23~17 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c5274b7f42ae2a83e75526293bc06826c03fe5d6;p=thirdparty%2Fdovecot%2Fcore.git director: Don't re-send SYNC unnecessarily often. --- diff --git a/src/director/director-connection.c b/src/director/director-connection.c index fd301b795b..9c058f2150 100644 --- a/src/director/director-connection.c +++ b/src/director/director-connection.c @@ -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; diff --git a/src/director/director.c b/src/director/director.c index 4eef160503..10896c2039 100644 --- a/src/director/director.c +++ b/src/director/director.c @@ -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); @@ -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); diff --git a/src/director/director.h b/src/director/director.h index 27ea46f051..a2e5c5469f 100644 --- a/src/director/director.h +++ b/src/director/director.h @@ -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;