]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/V2Writable.pm
v2writable: allow disabling parallelization
[public-inbox.git] / lib / PublicInbox / V2Writable.pm
index 36901cdea0c33e69dd538f70f7f0acd40932eb4f..8e1363ea732895da043cb5080502d65afdbc66b1 100644 (file)
@@ -56,6 +56,7 @@ sub new {
                xap_rw => undef, # PublicInbox::V2SearchIdx
                xap_ro => undef,
                partitions => $nparts,
+               parallel => 1,
                transact_bytes => 0,
                lock_path => "$dir/inbox.lock",
                # limit each repo to 1GB or so
@@ -93,7 +94,7 @@ sub add {
        my $nparts = $self->{partitions};
        my $part = $num % $nparts;
        my $idx = $self->idx_part($part);
-       $idx->index_raw($len, $msgref, $num, $oid, $mid0);
+       $idx->index_raw($len, $msgref, $num, $oid, $mid0, $mime);
        my $n = $self->{transact_bytes} += $len;
        if ($n > (PublicInbox::SearchIdx::BATCH_BYTES * $nparts)) {
                $self->checkpoint;
@@ -249,10 +250,11 @@ sub remove {
 
 sub done {
        my ($self) = @_;
+       my $locked = defined $self->{idx_parts};
        my $im = delete $self->{im};
        $im->done if $im; # PublicInbox::Import::done
        $self->searchidx_checkpoint(0);
-       $self->lock_release;
+       $self->lock_release if $locked;
 }
 
 sub checkpoint {
@@ -279,7 +281,7 @@ sub barrier {
                # Now deal with Xapian
                $skel->barrier_init(scalar(@$parts));
                # each partition needs to issue a barrier command to skel:
-               $_->barrier foreach @$parts;
+               $_->remote_barrier foreach @$parts;
 
                $skel->barrier_wait; # wait for each Xapian partition