]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
director: Don't re-send SYNC unnecessarily often.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 24 Mar 2016 00:42:50 +0000 (09:42 +0900)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 29 Mar 2016 08:21:24 +0000 (11:21 +0300)
src/director/director-connection.c
src/director/director.c
src/director/director.h

index fd301b795b92ecb6c304fed049468808a607fa12..9c058f2150d9550d1377bc9f7455f0b5f3c2ffa7 100644 (file)
@@ -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;
index 4eef160503f439272208350ab6fdf41e7c64d5e7..10896c20395a209a894290661e2011681dd0a31c 100644 (file)
@@ -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);
index 27ea46f0516d8f9fc20e750c8a2d3b3e14ec605d..a2e5c5469fcff9ca0555421ca1da1fc37893627e 100644 (file)
@@ -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;