]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Always fix inconsistency when syncing private flags index
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 12 Dec 2019 10:36:23 +0000 (12:36 +0200)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Mon, 16 Dec 2019 13:10:12 +0000 (13:10 +0000)
The flags index can't be fully synced with the main index at all times
anyway, so don't even try. Just fully sync it always and fix any found
inconsistencies.

Fixes:
Error: dovecot.index.pvt reset, view is now inconsistent

src/lib-storage/index/index-sync-private.h
src/lib-storage/index/index-sync-pvt.c
src/lib-storage/index/index-sync.c
src/lib-storage/index/index-transaction.c

index 7d670c4ee91eebee816b9d5ca3ab0890821939df..1aefd9b98ab5f626fd6d7e9827be9de2309e50fb 100644 (file)
@@ -26,7 +26,6 @@ void index_sync_search_results_expunge(struct index_mailbox_sync_context *ctx);
 
 /* Returns 1 = ok, 0 = no private indexes, -1 = error */
 int index_mailbox_sync_pvt_init(struct mailbox *box, bool lock,
-                               enum mail_index_view_sync_flags flags,
                                struct index_mailbox_sync_pvt_context **ctx_r);
 int index_mailbox_sync_pvt_newmails(struct index_mailbox_sync_pvt_context *ctx,
                                    struct mailbox_transaction_context *trans);
index df50d03f27dd9f00c1bf8a4712afb5aade155c54..ef374be7c2e98e0ea9a0abfc63917798c1c472bb 100644 (file)
@@ -11,8 +11,6 @@ struct index_mailbox_sync_pvt_context {
        struct mail_index_view *view_pvt;
        struct mail_index_transaction *trans_pvt;
        struct mail_index_view *view_shared;
-
-       enum mail_index_view_sync_flags flags;
 };
 
 static int sync_pvt_expunges(struct index_mailbox_sync_pvt_context *ctx)
@@ -125,7 +123,6 @@ index_mailbox_sync_open(struct index_mailbox_sync_pvt_context *ctx, bool force)
 }
 
 int index_mailbox_sync_pvt_init(struct mailbox *box, bool lock,
-                               enum mail_index_view_sync_flags flags,
                                struct index_mailbox_sync_pvt_context **ctx_r)
 {
        struct index_mailbox_sync_pvt_context *ctx;
@@ -138,7 +135,6 @@ int index_mailbox_sync_pvt_init(struct mailbox *box, bool lock,
 
        ctx = i_new(struct index_mailbox_sync_pvt_context, 1);
        ctx->box = box;
-       ctx->flags = flags;
        if (lock) {
                if (index_mailbox_sync_open(ctx, TRUE) < 0) {
                        index_mailbox_sync_pvt_deinit(&ctx);
@@ -303,8 +299,13 @@ int index_mailbox_sync_pvt_view(struct index_mailbox_sync_pvt_context *ctx,
        if (index_mailbox_sync_pvt_index(ctx, NULL, 0) < 0)
                return -1;
 
-       /* sync the private view */
-       view_sync_ctx = mail_index_view_sync_begin(ctx->box->view_pvt, ctx->flags);
+       /* Sync the private view. The flags index can't be fully synced with
+          the main index at all times anyway, so don't even try. Just fully
+          sync it always and fix any found inconsistencies. This way we also
+          avoid any unnecessary "dovecot.index.pvt reset, view is now
+          inconsistent" errors. */
+       view_sync_ctx = mail_index_view_sync_begin(ctx->box->view_pvt,
+               MAIL_INDEX_VIEW_SYNC_FLAG_FIX_INCONSISTENT);
        while (mail_index_view_sync_next(view_sync_ctx, &sync_rec)) {
                if (sync_rec.type != MAIL_INDEX_VIEW_SYNC_TYPE_FLAGS)
                        continue;
index 16707d24cf0bb8e618a415ae554b3afe65bf5a6d..1c2da95a78735fd6f795eb8dc99880cbcb587a44 100644 (file)
@@ -144,7 +144,7 @@ index_mailbox_sync_init(struct mailbox *box, enum mailbox_sync_flags flags,
           doesn't matter if it's called at _sync_init() or _sync_deinit().
           however we also need to know if any private flags have changed
           since last sync, so we need to call it before _sync_next() calls. */
-       if (index_mailbox_sync_pvt_init(box, FALSE, sync_flags, &pvt_ctx) > 0) {
+       if (index_mailbox_sync_pvt_init(box, FALSE, &pvt_ctx) > 0) {
                (void)index_mailbox_sync_pvt_view(pvt_ctx, &ctx->flag_updates,
                                                  &ctx->hidden_updates);
                index_mailbox_sync_pvt_deinit(&pvt_ctx);
index 017f387ce99f89ab12147ccc25048ed6f38da965..85c94a92f7ff01df22be7281bd823c9358af7986 100644 (file)
@@ -60,7 +60,7 @@ index_transaction_index_commit(struct mail_index_transaction *index_trans,
        }
 
        if (array_is_created(&t->pvt_saves)) {
-               if (index_mailbox_sync_pvt_init(t->box, TRUE, 0, &pvt_sync_ctx) < 0)
+               if (index_mailbox_sync_pvt_init(t->box, TRUE, &pvt_sync_ctx) < 0)
                        ret = -1;
        }