# HG changeset patch # User Timo Sirainen # Date 1313522772 -10800 # Node ID 2d4175c9ff520a2121cf1225a1debe8314ded1c6 # Parent 86d752132290ace481fb5a8656ab3c58762164a9 fts-lucene: Don't add messages to expunge log that aren't even in the index. diff -r 86d752132290 -r 2d4175c9ff52 src/plugins/fts-lucene/fts-backend-lucene.c --- a/src/plugins/fts-lucene/fts-backend-lucene.c Tue Aug 16 22:23:48 2011 +0300 +++ b/src/plugins/fts-lucene/fts-backend-lucene.c Tue Aug 16 22:26:12 2011 +0300 @@ -37,6 +37,7 @@ struct mailbox *box; uint32_t last_uid; + uint32_t last_indexed_uid; char *first_box_vname; uint32_t uid; @@ -46,6 +47,7 @@ struct fts_expunge_log_append_ctx *expunge_ctx; bool lucene_opened; + bool last_indexed_uid_set; }; static int fts_backend_lucene_mkdir(struct lucene_fts_backend *backend) @@ -276,6 +278,7 @@ if (ctx->first_box_vname == NULL) ctx->first_box_vname = i_strdup(box->vname); ctx->box = box; + ctx->last_indexed_uid_set = FALSE; } static void @@ -287,6 +290,21 @@ struct lucene_fts_backend *backend = (struct lucene_fts_backend *)_ctx->backend; + if (!ctx->last_indexed_uid_set) { + if (!fts_index_get_last_uid(ctx->box, &ctx->last_indexed_uid)) + ctx->last_indexed_uid = 0; + ctx->last_indexed_uid_set = TRUE; + } + if (ctx->last_indexed_uid == 0 || + uid > ctx->last_indexed_uid + 100) { + /* don't waste time adding expunge to log for a message that + isn't even indexed. this check is racy, because indexer may + just be in the middle of indexing this message. we'll + attempt to avoid that by skipping the expunging only if + indexing hasn't been done for a while (100 msgs). */ + return; + } + if (ctx->expunge_ctx == NULL) { ctx->expunge_ctx = fts_expunge_log_append_begin(backend->expunge_log);