From: Timo Sirainen Date: Tue, 31 Mar 2020 12:21:28 +0000 (+0300) Subject: lib-index: Log a warning if cache purging causes changes to be lost X-Git-Tag: 2.3.11.2~366 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0204437f592e87f20e13703c164b9bcc85f8c655;p=thirdparty%2Fdovecot%2Fcore.git lib-index: Log a warning if cache purging causes changes to be lost --- diff --git a/src/lib-index/mail-cache-transaction.c b/src/lib-index/mail-cache-transaction.c index 3a96c4d5c9..21378adc4e 100644 --- a/src/lib-index/mail-cache-transaction.c +++ b/src/lib-index/mail-cache-transaction.c @@ -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);