about summary refs log tree commit homepage
path: root/lib/PublicInbox/SearchIdx.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2016-07-31 00:02:05 +0000
committerEric Wong <e@80x24.org>2016-07-31 01:15:58 +0000
commit3a988efc28064954e64419bb0d368684fa7c7f20 (patch)
tree0d91879fc8b7cb197a927af9990c160c10716982 /lib/PublicInbox/SearchIdx.pm
parent4f9325bd4c9a8f971ab6e37aa449ee6958ec95e9 (diff)
downloadpublic-inbox-3a988efc28064954e64419bb0d368684fa7c7f20.tar.gz
We want transactions to be the responsibility of the
caller when possible; this fixes the potential for
the msgmap to internally become inconsistent when
using it from inside searchidx.
Diffstat (limited to 'lib/PublicInbox/SearchIdx.pm')
-rw-r--r--lib/PublicInbox/SearchIdx.pm11
1 files changed, 3 insertions, 8 deletions
diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm
index c2bf9a2d..3f2643c6 100644
--- a/lib/PublicInbox/SearchIdx.pm
+++ b/lib/PublicInbox/SearchIdx.pm
@@ -369,18 +369,18 @@ sub _index_sync {
                         # Common case is the indexes are synced,
                         # we only need to run git-log once:
                         $lx = $self->rlog($range, *index_both, *unindex_both);
-                        $mm->{dbh}->commit;
                         if (defined $lx) {
                                 $db->set_metadata('last_commit', $lx);
                                 $mm->last_commit($lx);
                         }
+                        $mm->{dbh}->commit;
                 } else {
                         # dumb case, msgmap and xapian are out-of-sync
                         # do not care for performance:
                         my $r = $lm eq '' ? $head : "$lm..$head";
                         $lm = $self->rlog($r, *index_mm, *unindex_mm);
-                        $mm->{dbh}->commit;
                         $mm->last_commit($lm) if defined $lm;
+                        $mm->{dbh}->commit;
 
                         $lx = $self->rlog($range, *index_mm2, *unindex_mm2);
                         $db->set_metadata('last_commit', $lx) if defined $lx;
@@ -390,12 +390,7 @@ sub _index_sync {
                 $lx = $self->rlog($range, *index_blob, *unindex_blob);
                 $db->set_metadata('last_commit', $lx) if defined $lx;
         }
-        if ($@) {
-                $db->cancel_transaction;
-                $mm->{dbh}->rollback if $mm;
-        } else {
-                $db->commit_transaction;
-        }
+        $db->commit_transaction;
 }
 
 # this will create a ghost as necessary