]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
dsync: Ignore missing remote mailbox when doing unidirectional sync
authorAki Tuomi <aki.tuomi@dovecot.fi>
Tue, 5 Sep 2017 07:43:46 +0000 (10:43 +0300)
committerAki Tuomi <aki.tuomi@dovecot.fi>
Tue, 5 Sep 2017 09:57:50 +0000 (12:57 +0300)
If there are some folders on remote system that
are being ignored by remote brain, do not error out.

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

index 454d90ceb48046f04198eaaa22e9312a526aa6cc..f4faa34f87c92e751470b459a0cde0aa7fa5fac2 100644 (file)
@@ -719,7 +719,8 @@ bool dsync_brain_mailbox_update_pre(struct dsync_brain *brain,
 
 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 @@ dsync_brain_slave_send_mailbox_lost(struct dsync_brain *brain,
        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 @@ bool dsync_brain_slave_recv_mailbox(struct dsync_brain *brain)
                                        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 @@ bool dsync_brain_slave_recv_mailbox(struct dsync_brain *brain)
                                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 @@ bool dsync_brain_slave_recv_mailbox(struct dsync_brain *brain)
        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;
        }
 
index 59dc052cfef77d131d57d58c5e7b1762db45aad0..44e53038c672fe11c4af1373f11cff37cedf38ef 100644 (file)
@@ -41,6 +41,15 @@ static bool dsync_brain_master_sync_recv_mailbox(struct dsync_brain *brain)
                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 */
index 1795443b2d70a0cccf0d2366e3cd18b484155651..878013821f92b7bac9c44729174c72562b511c69 100644 (file)
@@ -102,7 +102,8 @@ static const struct {
          .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',
@@ -1310,6 +1311,8 @@ dsync_ibc_stream_send_mailbox(struct dsync_ibc *_ibc,
 
        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)
@@ -1414,6 +1417,8 @@ dsync_ibc_stream_recv_mailbox(struct dsync_ibc *_ibc,
 
        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) ||
index 4e0254369c3a0c0b91a97a19f0bd7ce490b34792..d3dda9ddbb4885c5541bd9995552f96cc2d1e60c 100644 (file)
@@ -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;