dovecot-2.1: fts-solr: Don't send delete to Solr if we're quite ...
dovecot at dovecot.org
dovecot at dovecot.org
Fri Sep 2 07:11:33 EEST 2011
details: http://hg.dovecot.org/dovecot-2.1/rev/338ba56340c0
changeset: 13369:338ba56340c0
user: Timo Sirainen <tss at iki.fi>
date: Fri Sep 02 07:11:16 2011 +0300
description:
fts-solr: Don't send delete to Solr if we're quite sure it doesn't exist.
diffstat:
src/plugins/fts-solr/fts-backend-solr.c | 42 +++++++++++++++++++++++++-------
1 files changed, 32 insertions(+), 10 deletions(-)
diffs (66 lines):
diff -r 1c2d8da38a06 -r 338ba56340c0 src/plugins/fts-solr/fts-backend-solr.c
--- a/src/plugins/fts-solr/fts-backend-solr.c Thu Sep 01 17:52:51 2011 +0300
+++ b/src/plugins/fts-solr/fts-backend-solr.c Fri Sep 02 07:11:16 2011 +0300
@@ -32,9 +32,13 @@
uint32_t prev_uid;
string_t *cmd, *hdr, *hdr_fields;
- bool headers_open;
- bool cur_header_index;
- bool documents_added;
+ uint32_t last_indexed_uid;
+
+ unsigned int last_indexed_uid_set:1;
+ unsigned int headers_open:1;
+ unsigned int cur_header_index:1;
+ unsigned int documents_added:1;
+ unsigned int expunges:1;
};
static struct solr_connection *solr_conn = NULL;
@@ -294,13 +298,15 @@
if (fts_backed_solr_build_commit(ctx) < 0)
ret = -1;
- /* commit and wait until the documents we just indexed are
- visible to the following search */
- str = t_strdup_printf("<commit waitFlush=\"false\" "
- "waitSearcher=\"%s\"/>",
- ctx->documents_added ? "true" : "false");
- if (solr_connection_post(solr_conn, str) < 0)
- ret = -1;
+ if (ctx->documents_added || ctx->expunges) {
+ /* commit and wait until the documents we just indexed are
+ visible to the following search */
+ str = t_strdup_printf("<commit waitFlush=\"false\" "
+ "waitSearcher=\"%s\"/>",
+ ctx->documents_added ? "true" : "false");
+ if (solr_connection_post(solr_conn, str) < 0)
+ ret = -1;
+ }
str_free(&ctx->cmd);
str_free(&ctx->hdr);
@@ -340,6 +346,22 @@
{
struct solr_fts_backend_update_context *ctx =
(struct solr_fts_backend_update_context *)_ctx;
+ struct fts_index_header hdr;
+
+ if (!ctx->last_indexed_uid_set) {
+ if (!fts_index_get_header(ctx->cur_box, &hdr))
+ ctx->last_indexed_uid = 0;
+ else
+ ctx->last_indexed_uid = hdr.last_indexed_uid;
+ ctx->last_indexed_uid_set = TRUE;
+ }
+ if (ctx->last_indexed_uid == 0 ||
+ uid > ctx->last_indexed_uid + 100) {
+ /* don't waste time asking Solr to expunge a message that is
+ highly unlikely to be indexed at this time. */
+ return;
+ }
+ ctx->expunges = TRUE;
T_BEGIN {
string_t *cmd;
More information about the dovecot-cvs
mailing list