Skip to content

Commit

Permalink
fts: Log when indexing requires adding more mails to index than reque…
Browse files Browse the repository at this point in the history
…sted

This should mainly happen when FTS indexing is requested for a virtual
mailbox.
  • Loading branch information
sirainen committed Jun 18, 2017
1 parent 1c197c2 commit 77124c5
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/plugins/fts/fts-storage.c
Expand Up @@ -52,6 +52,7 @@ struct fts_transaction_context {
struct fts_scores *scores;
uint32_t next_index_seq;
uint32_t highest_virtual_uid;
unsigned int precache_extra_count;

bool precached:1;
bool mails_saved:1;
Expand Down Expand Up @@ -430,7 +431,7 @@ static int fts_mail_get_special(struct mail *_mail, enum mail_fetch_field field,
static int
fts_mail_precache_range(struct mailbox_transaction_context *trans,
struct fts_backend_update_context *update_ctx,
uint32_t seq1, uint32_t seq2)
uint32_t seq1, uint32_t seq2, unsigned int *extra_count)
{
struct mail_search_args *search_args;
struct mail_search_context *ctx;
Expand All @@ -451,6 +452,7 @@ fts_mail_precache_range(struct mailbox_transaction_context *trans,
break;
}
mail_precache(mail);
*extra_count += 1;
}
if (mailbox_search_deinit(&ctx) < 0)
ret = -1;
Expand Down Expand Up @@ -495,7 +497,8 @@ static void fts_mail_index(struct mail *_mail)
if (fts_mail_precache_range(_mail->transaction,
flist->update_ctx,
ft->next_index_seq,
_mail->seq-1) < 0) {
_mail->seq-1,
&ft->precache_extra_count) < 0) {
ft->failed = TRUE;
return;
}
Expand Down Expand Up @@ -586,6 +589,15 @@ static int fts_transaction_end(struct mailbox_transaction_context *t, const char
}
if (ft->scores != NULL)
fts_scores_unref(&ft->scores);
if (ft->precache_extra_count > 0) {
if (ret < 0) {
i_error("fts: Failed after indexing %u extra mails internally in %s: %s",
ft->precache_extra_count, t->box->vname, *error_r);
} else {
i_info("fts: Indexed %u extra mails internally in %s",
ft->precache_extra_count, t->box->vname);
}
}
i_free(ft);
return ret;
}
Expand Down

0 comments on commit 77124c5

Please sign in to comment.