]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
xcpdb: preserve has_threadid+skip_docdata across reshards
authorEric Wong <e@80x24.org>
Fri, 5 Dec 2025 07:44:26 +0000 (07:44 +0000)
committerEric Wong <e@80x24.org>
Sat, 6 Dec 2025 23:16:30 +0000 (23:16 +0000)
Neither the `has_threadid' nor `skip_docdata' metadata elements
ever got preserved properly across -xcpdb reshards.  This is a
long-standing bug which has existed since v1.6.

While omitting `skip_docdata' only wasted spacefor v2, omitting
`has_threadid' in copies causes missing search functionality as
part of the problem reported for the lore.k.o upgrade to v2.0.0.

Working around this bug after-the-fact requires the use of
xapian-metadata(1) on shard 0 of v2 inboxes and extindices:

xapian-metadata set /path/to/v2inbox/xap15/0 has_threadid 1
xapian-metadata set /path/to/extindex/ei15/0 has_threadid 1

Reported-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
Link: https://public-inbox.org/meta/20251204-modest-jaybird-of-will-9d55dc@lemur/
lib/PublicInbox/Xapcmd.pm
t/xcpdb-reshard.t

index 2cc48c8e2d2453444b6efb1d09f85320b9d0f5c2..476c6c4994642d1bff66b5a7cf5036629e3601f4 100644 (file)
@@ -598,11 +598,15 @@ sub cpdb ($$$) { # cb_spawn callback
                        my $lc = $src->get_metadata('last_commit');
                        $dst->set_metadata('last_commit', $lc) if $lc;
 
-                       # only the first xapian shard (0) gets 'indexlevel'
+                       # only the first xapian shard (0) gets metadata
                        if ($new =~ m!/(?:xapian[0-9]+|(?:ei|xap)[0-9]+/0)\b!) {
                                my $l = $src->get_metadata('indexlevel');
                                $l eq 'medium' and
                                        $dst->set_metadata('indexlevel', $l);
+                               for my $k (qw(has_threadid skip_docdata)) {
+                                       my $v = $src->get_metadata($k);
+                                       $dst->set_metadata($k, $v) if $v;
+                               }
                        }
                        if ($pr_data) {
                                my $tot = $src->get_doccount;
index 7797aaaf2fbe84d29243626f36cd787f8b5fa290..3f9ae11733b30d4e8d0d6af9610a9ed31fe16838 100644 (file)
@@ -1,5 +1,5 @@
 #!perl -w
-# Copyright (C) 2019-2021 all contributors <meta@public-inbox.org>
+# Copyright (C) all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 use strict;
 use v5.10.1;
@@ -47,6 +47,10 @@ for my $R (qw(2 4 1 3 3)) {
        ok(run_script($cmd, $env), "xcpdb -R$R");
        my @new_shards = grep(m!/\d+\z!, glob("$ibx->{inboxdir}/xap*/*"));
        is(scalar(@new_shards), $R, 'resharded to two shards');
+       is $ibx->search->xdb->get_metadata('has_threadid'),
+               '1', 'has_threadid set';
+       is $ibx->search->xdb->get_metadata('indexlevel'),
+               'medium', 'indexlevel preserved';
        my $mset = $ibx->search->mset('s:this');
        my $msgs = $ibx->search->mset_to_smsg($ibx, $mset);
        is(scalar(@$msgs), $ndoc, 'got expected docs after resharding');