Reopening Xapian DBs is a fairly cheap operation and Xapian
avoids doing work when nothing's changed, so just do it
to ensure we always get the latest updates in search results.
The old synchronous search interface worked around this by
having a timer based expiration in hopes of mitigating
fragmentation problems, but perhaps that's not worth doing
anymore now that memory fragmentation from Perl itself is
better understood.
or return;
my $dirs = delete $req->{d} or die 'no -d args';
my $key = join("\0", @$dirs);
+ my $new;
$req->{srch} = $SRCH{$key} //= do {
- my $new = { qp_flags => $PublicInbox::Search::QP_FLAGS };
+ $new = { qp_flags => $PublicInbox::Search::QP_FLAGS };
my $first = shift @$dirs;
my $slow_phrase = -f "$first/iamchert";
$new->{xdb} = $X->{Database}->new($first);
$new->{qp} = $new->qparse_new;
$new;
};
+ $req->{srch}->{xdb}->reopen unless $new;
$req->{Q} && !$req->{srch}->{qp_extra_done} and
srch_init_extra $req;
my $timeo = $req->{K};
req->srch = *s;
if (req->srch != kbuf.srch) { // reuse existing
free_srch(kbuf.srch);
+ req->srch->db->reopen();
} else if (!srch_init(req)) {
assert(kbuf.srch == *((struct srch **)tfind(
kbuf.srch, &srch_tree, srch_cmp)));