changeset 19954:82ffadc8c4d7

director: Don't re-send SYNC unnecessarily often.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Thu, 24 Mar 2016 09:42:50 +0900
parents a502d38e7b70
children 4ed6a9d7c232
files src/director/director-connection.c src/director/director.c src/director/director.h
diffstat 3 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/director/director-connection.c	Thu Mar 24 09:36:14 2016 +0900
+++ b/src/director/director-connection.c	Thu Mar 24 09:42:50 2016 +0900
@@ -1444,7 +1444,14 @@
 			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;
--- a/src/director/director.c	Thu Mar 24 09:36:14 2016 +0900
+++ b/src/director/director.c	Thu Mar 24 09:42:50 2016 +0900
@@ -325,6 +325,9 @@
 {
 	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 @@
 {
 	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);
--- a/src/director/director.h	Thu Mar 24 09:36:14 2016 +0900
+++ b/src/director/director.h	Thu Mar 24 09:42:50 2016 +0900
@@ -77,6 +77,8 @@
 
 	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;