changeset 22494:1f8b784712e1

dsync: Ignore missing remote mailbox when doing unidirectional sync If there are some folders on remote system that are being ignored by remote brain, do not error out.
author Aki Tuomi <aki.tuomi@dovecot.fi>
date Tue, 05 Sep 2017 10:43:46 +0300
parents a7af9490a266
children f08143f2f247
files src/doveadm/dsync/dsync-brain-mailbox.c src/doveadm/dsync/dsync-brain-mails.c src/doveadm/dsync/dsync-ibc-stream.c src/doveadm/dsync/dsync-mailbox.h
diffstat 4 files changed, 26 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/doveadm/dsync/dsync-brain-mailbox.c	Fri Aug 18 14:58:37 2017 +0300
+++ b/src/doveadm/dsync/dsync-brain-mailbox.c	Tue Sep 05 10:43:46 2017 +0300
@@ -719,7 +719,8 @@
 
 static void
 dsync_brain_slave_send_mailbox_lost(struct dsync_brain *brain,
-				    const struct dsync_mailbox *dsync_box)
+				    const struct dsync_mailbox *dsync_box,
+				    bool ignore)
 {
 	struct dsync_mailbox delete_box;
 
@@ -732,7 +733,10 @@
 	memcpy(delete_box.mailbox_guid, dsync_box->mailbox_guid,
 	       sizeof(delete_box.mailbox_guid));
 	t_array_init(&delete_box.cache_fields, 0);
-	delete_box.mailbox_lost = TRUE;
+	if (ignore)
+		delete_box.mailbox_ignore = TRUE;
+	else
+		delete_box.mailbox_lost = TRUE;
 	dsync_ibc_send_mailbox(brain->ibc, &delete_box);
 }
 
@@ -773,14 +777,14 @@
 					brain->master_brain ? 'M' : 'S',
 					guid_128_to_string(dsync_box->mailbox_guid));
 			}
-			dsync_brain_slave_send_mailbox_lost(brain, dsync_box);
+			dsync_brain_slave_send_mailbox_lost(brain, dsync_box, TRUE);
 			return TRUE;
 		}
 		//FIXME: verify this from log, and if not log an error.
 		dsync_brain_set_changes_during_sync(brain, t_strdup_printf(
 			"Mailbox GUID %s was lost",
 			guid_128_to_string(dsync_box->mailbox_guid)));
-		dsync_brain_slave_send_mailbox_lost(brain, dsync_box);
+		dsync_brain_slave_send_mailbox_lost(brain, dsync_box, FALSE);
 		return TRUE;
 	}
 	if (mailbox_sync(box, MAILBOX_SYNC_FLAG_FULL_READ) < 0) {
@@ -805,7 +809,7 @@
 				brain->master_brain ? 'M' : 'S',
 				guid_128_to_string(dsync_box->mailbox_guid));
 		}
-		dsync_brain_slave_send_mailbox_lost(brain, dsync_box);
+		dsync_brain_slave_send_mailbox_lost(brain, dsync_box, FALSE);
 		return TRUE;
 	}
 	i_assert(local_dsync_box.uid_validity != 0);
@@ -836,7 +840,7 @@
 	if (ret == 0 || resync) {
 		brain->require_full_resync = TRUE;
 		dsync_brain_sync_mailbox_deinit(brain);
-		dsync_brain_slave_send_mailbox_lost(brain, dsync_box);
+		dsync_brain_slave_send_mailbox_lost(brain, dsync_box, FALSE);
 		return TRUE;
 	}
 
--- a/src/doveadm/dsync/dsync-brain-mails.c	Fri Aug 18 14:58:37 2017 +0300
+++ b/src/doveadm/dsync/dsync-brain-mails.c	Tue Sep 05 10:43:46 2017 +0300
@@ -41,6 +41,15 @@
 		return TRUE;
 	}
 
+	if (dsync_box->mailbox_ignore) {
+		/* ignore this box */
+		if (brain->debug)
+			i_debug("brain %c: Ignoring missing remote box GUID %s",
+				brain->master_brain ? 'M' : 'S',
+			        guid_128_to_string(dsync_box->mailbox_guid));
+		dsync_brain_sync_mailbox_deinit(brain);
+		return TRUE;
+	}
 	if (dsync_box->mailbox_lost) {
 		/* remote lost the mailbox. it's probably already deleted, but
 		   verify it on next sync just to be sure */
--- a/src/doveadm/dsync/dsync-ibc-stream.c	Fri Aug 18 14:58:37 2017 +0300
+++ b/src/doveadm/dsync/dsync-ibc-stream.c	Tue Sep 05 10:43:46 2017 +0300
@@ -102,7 +102,8 @@
 	  .chr = 'B',
 	  .required_keys = "mailbox_guid uid_validity uid_next messages_count "
 		"first_recent_uid highest_modseq highest_pvt_modseq",
-	  .optional_keys = "mailbox_lost cache_fields have_guids have_save_guids have_only_guid128"
+	  .optional_keys = "mailbox_lost mailbox_ignore "
+			   "cache_fields have_guids have_save_guids have_only_guid128"
 	},
 	{ .name = "mailbox_attribute",
 	  .chr = 'A',
@@ -1313,6 +1314,8 @@
 
 	if (dsync_box->mailbox_lost)
 		dsync_serializer_encode_add(encoder, "mailbox_lost", "");
+	if (dsync_box->mailbox_ignore)
+		dsync_serializer_encode_add(encoder, "mailbox_ignore", "");
 	if (dsync_box->have_guids)
 		dsync_serializer_encode_add(encoder, "have_guids", "");
 	if (dsync_box->have_save_guids)
@@ -1417,6 +1420,8 @@
 
 	if (dsync_deserializer_decode_try(decoder, "mailbox_lost", &value))
 		box->mailbox_lost = TRUE;
+	if (dsync_deserializer_decode_try(decoder, "mailbox_ignore", &value))
+		box->mailbox_ignore = TRUE;
 	if (dsync_deserializer_decode_try(decoder, "have_guids", &value))
 		box->have_guids = TRUE;
 	if (dsync_deserializer_decode_try(decoder, "have_save_guids", &value) ||
--- a/src/doveadm/dsync/dsync-mailbox.h	Fri Aug 18 14:58:37 2017 +0300
+++ b/src/doveadm/dsync/dsync-mailbox.h	Tue Sep 05 10:43:46 2017 +0300
@@ -8,6 +8,7 @@
 struct dsync_mailbox {
 	guid_128_t mailbox_guid;
 	bool mailbox_lost;
+	bool mailbox_ignore;
 	bool have_guids, have_save_guids, have_only_guid128;
 
 	uint32_t uid_validity, uid_next, messages_count, first_recent_uid;