diff options
author | Eric Wong <e@80x24.org> | 2024-05-19 21:55:07 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2024-05-20 18:29:47 +0000 |
commit | 7a0d3890fce776950b4a4355d957e5a281db7ee0 (patch) | |
tree | 6911b6028f667eb34b4593d5a7cbb0ba33c9901a /lib/PublicInbox/XapHelper.pm | |
parent | cc970c759776fb9a4705af6a61ce9f65ca48c07b (diff) | |
download | public-inbox-7a0d3890fce776950b4a4355d957e5a281db7ee0.tar.gz |
This allows the process to recover in case we get the SHARD_COST calculation wrong in case Xapian uses more FDs than expected in new versions. We'll no longer attempt to recover from ENOMEM and similar errors during Xapian DB initialization and instead just tear down the process (as we do in other places).
Diffstat (limited to 'lib/PublicInbox/XapHelper.pm')
-rw-r--r-- | lib/PublicInbox/XapHelper.pm | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/lib/PublicInbox/XapHelper.pm b/lib/PublicInbox/XapHelper.pm index db9e99ae..ba41b5d2 100644 --- a/lib/PublicInbox/XapHelper.pm +++ b/lib/PublicInbox/XapHelper.pm @@ -202,14 +202,27 @@ sub dispatch { %SRCH = (); } my $first = shift @$dirs; - my $slow_phrase = -f "$first/iamchert"; - $new->{xdb} = $X->{Database}->new($first); - for (@$dirs) { - $slow_phrase ||= -f "$_/iamchert"; - $new->{xdb}->add_database($X->{Database}->new($_)); + for my $retried (0, 1) { + my $slow_phrase = -f "$first/iamchert"; + eval { + $new->{xdb} = $X->{Database}->new($first); + for (@$dirs) { + $slow_phrase ||= -f "$_/iamchert"; + $new->{xdb}->add_database( + $X->{Database}->new($_)) + } + }; + last unless $@; + if ($retried) { + die "E: $@\n"; + } else { # may be EMFILE/ENFILE/ENOMEM.... + warn "W: $@, retrying...\n"; + %SRCH = (); + $SHARD_NFD = $nfd; + } + $slow_phrase or $new->{qp_flags} + |= PublicInbox::Search::FLAG_PHRASE(); } - $slow_phrase or - $new->{qp_flags} |= PublicInbox::Search::FLAG_PHRASE(); bless $new, $req->{c} ? 'PublicInbox::CodeSearch' : 'PublicInbox::Search'; $new->{qp} = $new->qparse_new; |