# HG changeset patch # User Timo Sirainen # Date 1511190227 -7200 # Node ID e6a9ff4a07d5b8525ad3ef6b748bd98870d293f3 # Parent 15f548f4d144ff4fb5ae653a53adc63056ffbc9a mdbox: Fix rebuilding when dovecot.map.index is missing map/ref extension The rebuild kept just repeatedly failing with: Error: mdbox map .../dovecot.map.index corrupted: missing map extension diff -r 15f548f4d144 -r e6a9ff4a07d5 src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c --- a/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Thu Jan 04 12:44:16 2018 -0500 +++ b/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Mon Nov 20 17:03:47 2017 +0200 @@ -331,7 +331,7 @@ } } -static int rebuild_apply_map(struct mdbox_storage_rebuild_context *ctx) +static void rebuild_apply_map(struct mdbox_storage_rebuild_context *ctx) { struct mdbox_map *map = ctx->storage->map; const struct mail_index_header *hdr; @@ -347,8 +347,14 @@ hdr = mail_index_get_header(ctx->atomic->sync_view); for (seq = 1; seq <= hdr->messages_count; seq++) { if (mdbox_map_view_lookup_rec(map, ctx->atomic->sync_view, - seq, &rec) < 0) - return -1; + seq, &rec) < 0) { + /* map or ref extension is missing from the index. + Just ignore the file entirely. (Don't try to + continue with other records, since they'll fail + as well, and each failure logs the same error.) */ + i_assert(seq == 1); + break; + } /* look up the rebuild msg record for this message based on the (file_id, offset, size) triplet */ @@ -373,7 +379,6 @@ /* afterwards we're interested in looking up map_uids. re-sort the messages to make it easier. */ array_sort(&ctx->msgs, mdbox_rebuild_msg_uid_cmp); - return 0; } static struct mdbox_rebuild_msg * @@ -944,8 +949,8 @@ return -1; } - if (rebuild_apply_map(ctx) < 0 || - rebuild_mailboxes(ctx) < 0 || + rebuild_apply_map(ctx); + if (rebuild_mailboxes(ctx) < 0 || rebuild_finish(ctx) < 0) { mdbox_map_atomic_set_failed(ctx->atomic); return -1;