Index Upgrade Bug

Bron Gondwana brong at fastmail.fm
Fri Aug 28 00:59:18 EDT 2009


Found something else fun.  It appears that squatter considers
a short string (< 4 bytes) too short to search on, but rather
than just skipping over it for the prefilter, it bails on the
whole prefiltering stage!

I'm in two minds about considering _ANY_ error non-fatal and
just grounds for not restricting the search space actually,
but short strings are clearly bogus.

SEARCH BODY "rare string" SUBJECT "hi"

will currently wind up scanning every single message even if
you have squatted the mailbox, while:

SEARCH BODY "rare string" SUBJECT "hello"

will not.  Annoying.

Here's the patch:

diff --git a/imap/search_engines.c b/imap/search_engines.c
index 7b013a1..8e7b8b8 100644
--- a/imap/search_engines.c
+++ b/imap/search_engines.c
@@ -161,6 +161,8 @@ static int search_strlist(SquatSearchIndex* index, struct mailbox* mailbox,
     memset(tmp, 0, len);
     if (squat_search_execute(index, s, strlen(s), fill_with_hits, &r)
         != SQUAT_OK) {
+      if (squat_get_last_error() == SQUAT_ERR_SEARCH_STRING_TOO_SHORT)
+        return 1; /* The rest of the search is still viable */
       syslog(LOG_DEBUG, "SQUAT string list search failed on string %s "
              "with part types %s", s, part_types);
       return 0;

I'll be applying this one to CVS soon as well.  I can't see any reason not
to do it!

It's tested, too :) - we're in the process of rolling out a "auto squat while
the caches are hot" system - basically it logs body searches and then runs
squatter (-i) if the prefilter wasn't very efficient (part of monitorcyrus.pl,
the only cyrus change is an auditlog: line for bodysearches)

Bron.


More information about the Cyrus-devel mailing list