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.
if ($writable) {
create_tables($dbh);
if ($writable) {
create_tables($dbh);
$self->created_at(time) unless $self->created_at;
$self->created_at(time) unless $self->created_at;
defined $value or
return $dbh->selectrow_array(meta_select, undef, $key);
defined $value or
return $dbh->selectrow_array(meta_select, undef, $key);
- $dbh->begin_work;
- eval {
- $prev = $dbh->selectrow_array(meta_select, undef, $key);
+ $prev = $dbh->selectrow_array(meta_select, undef, $key);
- if (defined $prev) {
- $dbh->do(meta_update, undef, $value, $key);
- } else {
- $dbh->do(meta_insert, undef, $key, $value);
- }
- $dbh->commit;
- };
- my $err = $@;
- return $prev unless $err;
-
- $dbh->rollback;
- die $err;
+ if (defined $prev) {
+ $dbh->do(meta_update, undef, $value, $key);
+ } else {
+ $dbh->do(meta_insert, undef, $key, $value);
+ }
+ $prev;
# Common case is the indexes are synced,
# we only need to run git-log once:
$lx = $self->rlog($range, *index_both, *unindex_both);
# Common case is the indexes are synced,
# we only need to run git-log once:
$lx = $self->rlog($range, *index_both, *unindex_both);
if (defined $lx) {
$db->set_metadata('last_commit', $lx);
$mm->last_commit($lx);
}
if (defined $lx) {
$db->set_metadata('last_commit', $lx);
$mm->last_commit($lx);
}
} 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);
} 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->last_commit($lm) if defined $lm;
$mm->last_commit($lm) if defined $lm;
$lx = $self->rlog($range, *index_mm2, *unindex_mm2);
$db->set_metadata('last_commit', $lx) if defined $lx;
$lx = $self->rlog($range, *index_mm2, *unindex_mm2);
$db->set_metadata('last_commit', $lx) if defined $lx;
$lx = $self->rlog($range, *index_blob, *unindex_blob);
$db->set_metadata('last_commit', $lx) if defined $lx;
}
$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
}
# this will create a ghost as necessary