]> Sergey Matveev's repositories - public-inbox.git/commitdiff
v2writable: convert some fatal reindex errors to warnings
authorEric Wong (Contractor, The Linux Foundation) <e@80x24.org>
Fri, 30 Mar 2018 01:20:42 +0000 (01:20 +0000)
committerEric Wong (Contractor, The Linux Foundation) <e@80x24.org>
Fri, 30 Mar 2018 01:21:01 +0000 (01:21 +0000)
By supporting purge and allowing users to delete git partitions,
we can open up ourselves to gaps and un-reindexible data.  Let
that be.

lib/PublicInbox/V2Writable.pm

index 6394d300fa2eb8e8d6f0287eaa7935c9233194f2..269b028f5373a9fb1e99ed7c2b8166c438c6d111 100644 (file)
@@ -552,7 +552,7 @@ sub reindex_oid {
                $num = $$regen--;
                die "BUG: ran out of article numbers\n" if $num <= 0;
                my $mm = $self->{skel}->{mm};
                $num = $$regen--;
                die "BUG: ran out of article numbers\n" if $num <= 0;
                my $mm = $self->{skel}->{mm};
-               foreach my $mid (@$mids) {
+               foreach my $mid (reverse @$mids) {
                        if ($mm->mid_set($num, $mid) == 1) {
                                $mid0 = $mid;
                                last;
                        if ($mm->mid_set($num, $mid) == 1) {
                                $mid0 = $mid;
                                last;
@@ -560,7 +560,11 @@ sub reindex_oid {
                }
                if (!defined($mid0)) {
                        my $id = '<' . join('> <', @$mids) . '>';
                }
                if (!defined($mid0)) {
                        my $id = '<' . join('> <', @$mids) . '>';
-                       warn "Message-Id $id unusable for $num\n";
+                       warn "Message-ID $id unusable for $num\n";
+                       foreach my $mid (@$mids) {
+                               defined(my $n = $mm->num_for($mid)) or next;
+                               warn "#$n previously mapped for <$mid>\n";
+                       }
                }
        }
 
                }
        }
 
@@ -661,8 +665,17 @@ sub reindex {
                }
                delete $self->{reindex_pipe};
        }
                }
                delete $self->{reindex_pipe};
        }
+       my $gaps;
+       if ($regen && $$regen != 0) {
+               warn "W: leftover article number ($$regen)\n";
+               $gaps = 1;
+       }
        my ($min, $max) = $mm_tmp->minmax;
        my ($min, $max) = $mm_tmp->minmax;
-       defined $max and die "leftover article numbers at $min..$max\n";
+       if (defined $max) {
+               warn "W: leftover article numbers at $min..$max\n";
+               $gaps = 1;
+       }
+       warn "W: were old git partitions deleted?\n" if $gaps;
        my @d = sort keys %$D;
        if (@d) {
                warn "BUG: ", scalar(@d)," unseen deleted messages marked\n";
        my @d = sort keys %$D;
        if (@d) {
                warn "BUG: ", scalar(@d)," unseen deleted messages marked\n";