]> Sergey Matveev's repositories - public-inbox.git/commitdiff
extsearchidx: close SQLite handles after attaching
authorEric Wong <e@80x24.org>
Wed, 23 Dec 2020 08:38:49 +0000 (08:38 +0000)
committerEric Wong <e@80x24.org>
Wed, 23 Dec 2020 23:46:41 +0000 (23:46 +0000)
This is needed to prevent us from running out of FDs when
indexing many inboxes.  Perhaps checking these on attach_inbox
is unnecessary and may be removed entirely down the line.

lib/PublicInbox/ExtSearchIdx.pm

index 9d64ff5a9a56c38b994f8a2da6cbc50829c9f837..fb62708934efc95de249fe1e6fc6a7517c4f7f83 100644 (file)
@@ -65,11 +65,14 @@ sub attach_inbox {
        my $misc = $self->{misc};
        if ($misc && $misc->inbox_data($ibx)) { # all good if already indexed
        } else {
-               if (!$ibx->over || !$ibx->mm) {
+               my @sqlite = ($ibx->over, $ibx->mm);
+               my $uidvalidity = $ibx->uidvalidity;
+               $ibx->{mm} = $ibx->{over} = undef;
+               if (scalar(@sqlite) != 2) {
                        warn "W: skipping $ekey (unindexed)\n";
                        return;
                }
-               if (!defined($ibx->uidvalidity)) {
+               if (!defined($uidvalidity)) {
                        warn "W: skipping $ekey (no UIDVALIDITY)\n";
                        return;
                }