From: Timo Sirainen Date: Thu, 12 Dec 2019 10:36:23 +0000 (+0200) Subject: lib-storage: Always fix inconsistency when syncing private flags index X-Git-Tag: 2.3.10~181 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=986d9cbbecffd836d977b6ad956b04e3ca606677;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: Always fix inconsistency when syncing private flags index 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 --- diff --git a/src/lib-storage/index/index-sync-private.h b/src/lib-storage/index/index-sync-private.h index 7d670c4ee9..1aefd9b98a 100644 --- a/src/lib-storage/index/index-sync-private.h +++ b/src/lib-storage/index/index-sync-private.h @@ -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); diff --git a/src/lib-storage/index/index-sync-pvt.c b/src/lib-storage/index/index-sync-pvt.c index df50d03f27..ef374be7c2 100644 --- a/src/lib-storage/index/index-sync-pvt.c +++ b/src/lib-storage/index/index-sync-pvt.c @@ -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; diff --git a/src/lib-storage/index/index-sync.c b/src/lib-storage/index/index-sync.c index 16707d24cf..1c2da95a78 100644 --- a/src/lib-storage/index/index-sync.c +++ b/src/lib-storage/index/index-sync.c @@ -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); diff --git a/src/lib-storage/index/index-transaction.c b/src/lib-storage/index/index-transaction.c index 017f387ce9..85c94a92f7 100644 --- a/src/lib-storage/index/index-transaction.c +++ b/src/lib-storage/index/index-transaction.c @@ -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; }