]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: After recreating cache, make sure offsets are immediately updated to map
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 8 Jul 2019 15:56:12 +0000 (18:56 +0300)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 8 Jul 2019 17:03:20 +0000 (20:03 +0300)
They were most likely refreshed anyway before the next cache usage, but this
caused an assert-crash if the dovecot.index was also recreated in the same
sync.

Broken by e31b0637d8788885a71db2def5743ebf14c698f3

Fixes:
Panic: file mail-index-write.c: line 138 (mail_index_write): assertion failed: (file->hdr.prev_file_offset == hdr->log_file_head_offset)

src/lib-index/mail-index-sync.c

index a13355209775b9e7a6a53f0103774297fbb81d43..641ab7be6fba82dc753501b544978e9c2a03dda0 100644 (file)
@@ -937,6 +937,15 @@ int mail_index_sync_commit(struct mail_index_sync_ctx **_ctx)
                        /* can't really do anything if index commit fails */
                        (void)mail_index_transaction_commit(&cache_trans);
                        mail_cache_compress_unlock(&cache_lock);
+                       /* Make sure the newly committed cache record offsets
+                          are updated to the current index. This is important
+                          if the dovecot.index gets recreated below, because
+                          rotation of dovecot.index.log also re-maps the index
+                          to make sure everything is up-to-date. But if it
+                          wasn't, mail_index_write() will just assert-crash
+                          because log_file_head_offset changed. */
+                       if (mail_index_map(ctx->index, MAIL_INDEX_SYNC_HANDLER_FILE) <= 0)
+                               ret = -1;
                }
        }