]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Log a warning if cache purging causes changes to be lost
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 31 Mar 2020 12:21:28 +0000 (15:21 +0300)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 15 Apr 2020 09:41:43 +0000 (12:41 +0300)
src/lib-index/mail-cache-transaction.c

index 3a96c4d5c926f1eded167933986dd35fdec1fa44..21378adc4e5991da096af78bd2b7c4e113efbc3f 100644 (file)
@@ -127,12 +127,17 @@ static void
 mail_cache_transaction_forget_flushed(struct mail_cache_transaction_ctx *ctx,
                                      bool reset_id_changed)
 {
+       uint32_t new_cache_file_seq = MAIL_CACHE_IS_UNUSABLE(ctx->cache) ? 0 :
+               ctx->cache->hdr->file_seq;
        if (reset_id_changed && ctx->records_written > 0) {
+               e_warning(ctx->cache->event,
+                         "Purging lost %u written cache records "
+                         "(reset_id changed %u -> %u)", ctx->records_written,
+                         ctx->cache_file_seq, new_cache_file_seq);
                /* don't increase deleted_record_count in the new file */
                ctx->records_written = 0;
        }
-       ctx->cache_file_seq = MAIL_CACHE_IS_UNUSABLE(ctx->cache) ? 0 :
-               ctx->cache->hdr->file_seq;
+       ctx->cache_file_seq = new_cache_file_seq;
        /* forget all cache extension updates even if reset_id doesn't change */
        mail_index_ext_set_reset_id(ctx->trans, ctx->cache->ext_id,
                                    ctx->cache_file_seq);