Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge remote branch 'remotes/origin/v1.2.0-fixes'

Conflicts:
	lib/Manitou/Words.pm
  • Loading branch information...
commit 081e2227a78414ec60b9360414f8c668fc2e588c 2 parents 54c33ee + 93c01fc
@manitou-mail authored
Showing with 36 additions and 4 deletions.
  1. +33 −0 lib/Manitou/Words.pm
  2. +3 −4 script/manitou-mdx
View
33 lib/Manitou/Words.pm
@@ -195,6 +195,38 @@ sub clear_word_vectors {
%hwords=();
}
+# Clear the bits corresponding to a mail_id in the inverted word
+# index cache in memory.
+# Normally, this is always the last inserted mail, after is has been
+# rolled back
+# It's important to delete the vector if it's empty because the word
+# entry may not exist at all in the database and there's an FK constraint
+# from table inverted_word_index referencing table words.
+sub clear_last_indexed_mail {
+ my ($dbh,$mail_id)=@_;
+ load_partsize($dbh) if !defined($partsize);
+ my $part_no = $mail_id / $partsize;
+ my $bit_id = ($mail_id-1) % $partsize;
+
+ foreach my $wid (keys %vecs) {
+ if (exists $vecs{$wid}->{$part_no}->{dirty}) {
+ my $vec=$vecs{$wid}->{$part_no}->{v};
+ if ($vec->Size()>$bit_id && $vec->bit_test($bit_id)) {
+ $vec->Bit_Off($bit_id);
+ if ($vec->is_empty()) {
+ delete $vecs{$wid}->{$part_no};
+ }
+ else {
+ $vecs{$wid}->{$part_no}->{v}=$vec;
+ }
+ }
+ }
+ }
+ # since INSERT INTO words may have been rolled back,
+ # the cache of word_id can no longer be trusted, so it's reset
+ %hwords=();
+}
+
sub extract_words {
my ($ptext, $tb)=@_;
my %seen;
@@ -247,6 +279,7 @@ sub extract_words {
}
}
+
sub index_words {
my ($dbh, $mail_id, $pbody, $pheader)=@_;
load_partsize($dbh) if !defined($partsize);
View
7 script/manitou-mdx
@@ -901,14 +901,13 @@ sub import_message {
if ($@) {
if ($dbh->err > 0) {
error_log("Database error: $@");
- $dbh->rollback();
- return 0;
}
else {
error_log("Import error: $@");
- $dbh->rollback();
- return 0;
}
+ $dbh->rollback();
+ Manitou::Words::clear_last_indexed_mail($dbh, $mail_id) if ($mail_id>0);
+ return 0;
}
return $id;
}
Please sign in to comment.
Something went wrong with that request. Please try again.