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-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 6874D1FA12 for ; Tue, 15 Dec 2020 02:02:25 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 2/9] extindex: delete stale messages from over.sqlite3 Date: Tue, 15 Dec 2020 02:02:17 +0000 Message-Id: <20201215020224.11739-3-e@80x24.org> In-Reply-To: <20201215020224.11739-1-e@80x24.org> References: <20201215020224.11739-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: In addition to removing stale messages from Xapian, we must also remove them from over.sqlite3. --- lib/PublicInbox/ExtSearchIdx.pm | 1 + t/extsearch.t | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/lib/PublicInbox/ExtSearchIdx.pm b/lib/PublicInbox/ExtSearchIdx.pm index 394a89d4..ec86a7c0 100644 --- a/lib/PublicInbox/ExtSearchIdx.pm +++ b/lib/PublicInbox/ExtSearchIdx.pm @@ -533,6 +533,7 @@ DELETE FROM xref3 WHERE ibx_id = ? AND xnum = ? AND oidbin = ? my $xr3 = $self->{oidx}->get_xref3($docid); my $idx = $self->idx_shard($docid); if (scalar(@$xr3) == 0) { # all gone + $self->{oidx}->delete_by_num($docid); $self->{oidx}->eidxq_del($docid); $idx->shard_remove($docid); } else { # enqueue for reindex of remaining messages diff --git a/t/extsearch.t b/t/extsearch.t index f16ec0d1..4a8a9f49 100644 --- a/t/extsearch.t +++ b/t/extsearch.t @@ -268,18 +268,30 @@ if ('reindex catches missed messages') { my $new = $oidx->get_art($max + 1); is($new->{subject}, $eml->header('Subject'), 'new message added'); + $es->{xdb}->reopen; + my $mset = $es->mset("mid:$new->{mid}"); + is($mset->size, 1, 'previously unseen, now indexed in Xapian'); + ok($im->remove($eml), 'remove new message from v2 inbox'); $im->done; my $cmt_c = $v2ibx->mm->last_commit_xap($schema_version, 0); is($oidx->eidx_meta($lc_key, $cmt_c), $cmt_b, 'bump lc-v2 meta again to skip v2 remove'); $err = ''; + $oidx->dbh_close; ok(run_script([qw(-extindex --reindex), "$home/extindex", $v2ibx->{inboxdir}], undef, $opt), '--reindex for stale'); @err = split(/^/, $err); is(scalar(@err), 1, 'only one warning'); like($err[0], qr/\(#$new->{num}\): stale/, 'got stale message warning'); + is($oidx->get_art($new->{num}), undef, + 'stale message gone from over'); + is_deeply($oidx->get_xref3($new->{num}), [], + 'stale message has no xref3'); + $es->{xdb}->reopen; + $mset = $es->mset("mid:$new->{mid}"); + is($mset->size, 0, 'stale mid gone Xapian'); } if ('remove v1test and test gc') {