]> Sergey Matveev's repositories - public-inbox.git/commitdiff
v2writable: commit to skeleton via remote partitions
authorEric Wong (Contractor, The Linux Foundation) <e@80x24.org>
Tue, 27 Feb 2018 20:29:55 +0000 (20:29 +0000)
committerEric Wong (Contractor, The Linux Foundation) <e@80x24.org>
Wed, 28 Feb 2018 23:06:20 +0000 (23:06 +0000)
We need to ensure Xapian transaction commits are made to remote
partitions before associated commits hit the skeleton DB.

This causes unnecessary commits to be made to the skeleton DB;
but they're mostly harmless.  Further work will be necessary
to ensure proper ordering and avoidance of unnecessary commits.

lib/PublicInbox/SearchIdxPart.pm
lib/PublicInbox/V2Writable.pm

index 6025fc4034cf3e5837e873ef5c1645dd3c77825f..2f577ecff5a807d921ea9ddab0be7a802f008e25 100644 (file)
@@ -45,6 +45,7 @@ sub partition_worker_loop ($$$) {
                if ($line eq "commit\n") {
                        $xdb->commit_transaction if $txn;
                        $txn = undef;
+                       $self->{skeleton}->remote_commit;
                } elsif ($line eq "close\n") {
                        $self->_xdb_release;
                        $xdb = $txn = undef;
index ff3b6573dbd0029395dfb8457378d3ec72e6e1ad..73110ff06df6e1373bbee6ed991062e790843dc3 100644 (file)
@@ -131,22 +131,21 @@ sub searchidx_checkpoint {
 
        # order matters, we can only close {skel} after all partitions
        # are done because the partitions also write to {skel}
-
        if (my $parts = $self->{idx_parts}) {
                foreach my $idx (@$parts) {
-                       $idx->remote_commit;
+                       $idx->remote_commit; # propagates commit to skel
                        $idx->remote_close unless $more;
                }
                delete $self->{idx_parts} unless $more;
        }
 
        if (my $skel = $self->{skel}) {
-               $skel->{mm}->{dbh}->commit;
+               my $dbh = $skel->{mm}->{dbh};
+               $dbh->commit;
                if ($more) {
-                       $skel->{mm}->{dbh}->begin_work;
-               }
-               $skel->remote_commit;
-               unless ($more) {
+                       $dbh->begin_work;
+               } else {
+                       $skel->remote_commit; # XXX should be unnecessary...
                        $skel->remote_close;
                        delete $self->{skel};
                }