From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 97BC01F9FC for ; Sun, 17 Oct 2021 09:52:50 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 2/4] extindex: retry sync_inbox before reindex Date: Sat, 16 Oct 2021 22:52:48 -1100 Message-Id: <20211017095250.22252-3-e@80x24.org> In-Reply-To: <20211017095250.22252-1-e@80x24.org> References: <20211017095250.22252-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Ensure the num highwater mark of the target inbox is stable before using it. Otherwise we may end up repeating work done to index a message. --- lib/PublicInbox/ExtSearchIdx.pm | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/PublicInbox/ExtSearchIdx.pm b/lib/PublicInbox/ExtSearchIdx.pm index 67d720368922..daff656d1ac5 100644 --- a/lib/PublicInbox/ExtSearchIdx.pm +++ b/lib/PublicInbox/ExtSearchIdx.pm @@ -859,14 +859,20 @@ sub _reindex_check_ibx ($$$) { my $slice = 10000; my $opt = { limit => $slice }; my ($beg, $end) = (1, $slice); - my $err = sync_inbox($self, $sync, $ibx) and return; - my $max = $ibx->mm->num_highwater; + my $ekey = $ibx->eidx_key; + my ($max, $max0); + do { + $max0 = $ibx->mm->num_highwater; + sync_inbox($self, $sync, $ibx) and return; # warned + $max = $ibx->mm->num_highwater; + return if $sync->{quit}; + } while ($max > $max0 && + warn("# $ekey moved $max0..$max, resyncing..\n")); $end = $max if $end > $max; # first, check if we missed any messages in target $ibx my $msgs; my $pr = $sync->{-opt}->{-progress}; - my $ekey = $ibx->eidx_key; local $sync->{-regen_fmt} = "$ekey checking %u/$max\n"; ${$sync->{nr}} = 0; my $fast = $sync->{-opt}->{fast};