summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
12d2192)
We'll also fix the read-only code to ensure we notice missing
Xapian shards, since gaps would throw off our expectation that
Xapian document IDs and NNTP article numbers are interchangeable.
use strict;
use parent qw(Exporter);
our @EXPORT_OK = qw(mdocid);
use strict;
use parent qw(Exporter);
our @EXPORT_OK = qw(mdocid);
# values for searching, changing the numeric value breaks
# compatibility with old indices (so don't change them it)
# values for searching, changing the numeric value breaks
# compatibility with old indices (so don't change them it)
# We need numeric sorting so shard[0] is first for reading
# Xapian metadata, if needed
# We need numeric sorting so shard[0] is first for reading
# Xapian metadata, if needed
- for (sort { $a <=> $b } grep(/\A[0-9]+\z/, readdir($dh))) {
+ my $last = max(grep(/\A[0-9]+\z/, readdir($dh)));
+ return if !defined($last);
+ for (0..$last) {
my $shard_dir = "$dir/$_";
if (-d $shard_dir && -r _) {
push @xdb, $X{Database}->new($shard_dir);
my $shard_dir = "$dir/$_";
if (-d $shard_dir && -r _) {
push @xdb, $X{Database}->new($shard_dir);
sub count_shards ($) {
my ($self) = @_;
sub count_shards ($) {
my ($self) = @_;
- my $n = 0;
- my $xpfx = $self->{xpfx};
-
# always load existing shards in case core count changes:
# Also, shard count may change while -watch is running
# always load existing shards in case core count changes:
# Also, shard count may change while -watch is running
- # due to "xcpdb --reshard"
- if (-d $xpfx) {
- my $XapianDatabase;
- foreach my $shard (<$xpfx/*>) {
- -d $shard && $shard =~ m!/[0-9]+\z! or next;
- $XapianDatabase //= do {
- require PublicInbox::Search;
- PublicInbox::Search::load_xapian();
- $PublicInbox::Search::X{Database};
- };
- eval {
- $XapianDatabase->new($shard)->close;
- $n++;
- };
- }
- }
- $n;
+ my $srch = $self->{ibx}->search or return 0;
+ delete $self->{ibx}->{search};
+ $srch->{nshard} // 0