]> Sergey Matveev's repositories - public-inbox.git/commitdiff
v2writable: fix epoch rollover on incremental imports
authorEric Wong <e@80x24.org>
Wed, 27 Feb 2019 20:25:36 +0000 (20:25 +0000)
committerEric Wong <e@80x24.org>
Wed, 27 Feb 2019 20:26:21 +0000 (20:26 +0000)
All of our internal epoch rollover calculations are done using
the estimated unpacked (and uncompressed) size of the repo.  The
importer instance needs to check that unpacked size before
selecting an epoch when an epoch already has packed data.

This bug did not impact the initial mass imports since we only
initialize the Import instance once-per-epoch and did not need
to take existing epochs into account.

Tested manually with -mda on a local clone of LKML

Reported-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
lib/PublicInbox/V2Writable.pm

index 1f17fe212943a51af9b89071f28b07cd7ef74580..b1d8095f598408c76012f7ec8bf292f3feadde3f 100644 (file)
@@ -588,7 +588,9 @@ sub importer {
        if (defined $latest) {
                my $git = PublicInbox::Git->new($latest);
                my $packed_bytes = $git->packed_bytes;
-               if ($packed_bytes >= $self->{rotate_bytes}) {
+               my $unpacked_bytes = $packed_bytes / $PACKING_FACTOR;
+
+               if ($unpacked_bytes >= $self->{rotate_bytes}) {
                        $epoch = $max + 1;
                } else {
                        $self->{epoch_max} = $max;