]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
extmsg: fix Message-ID search for non-xap_helper users
authorEric Wong <e@80x24.org>
Tue, 21 Oct 2025 03:03:46 +0000 (03:03 +0000)
committerEric Wong <e@80x24.org>
Wed, 22 Oct 2025 19:30:47 +0000 (19:30 +0000)
commit c3d0295bd was intended to avoid head-of-line blocking for
--xapian-helpers (-X) deployments.  Unfortunately, that broke
searches for deployments not using --xapian-helpers by causing
the ExtMsg to get queued redundantly into the event loop.  So
perform the `requeue' procedure exactly once and simplify
ExtMsg->event_step by eliminating the $sync parameter.

Fixes: c3d0295bd (www: extmsg: async partial Message-ID search, 2025-05-12)
Reported-by: Kyle Meyer <kyle@kyleam.com>
Link: https://public-inbox.org/meta/877bwva3s4.fsf@kyleam.com/
lib/PublicInbox/ExtMsg.pm
t/extmsg_event_step_regression.t [new file with mode: 0644]

index 282db1d263ef3a27dd5cbf7a8f541e8227197e01..3e9b33a37aa330c7f420c00ea3d45af2934872a4 100644 (file)
@@ -137,7 +137,7 @@ sub partial_enter ($) {
        my ($ctx) = @_;
        bless $ctx, __PACKAGE__; # for ExtMsg->event_step
        return $ctx->event_step if $ctx->{env}->{'pi-httpd.app'};
-       $ctx->event_step(1) while $ctx->{-wcb};
+       $ctx->event_step while $ctx->{-wcb}; # generic PSGI
 }
 
 sub partial_prepare ($@) {
@@ -193,12 +193,10 @@ sub ext_msg {
 
 # called via PublicInbox::DS::event_loop
 sub event_step {
-       my ($ctx, $sync) = @_;
+       my ($ctx) = @_;
        # can't find a partial match in current inbox, try the others:
        my $ibx = shift @{$ctx->{again}} or return finalize_partial($ctx);
-       unless (partial_ibx_start($ctx, $ibx)) {
-               PublicInbox::DS::requeue($ctx) unless $sync;
-       }
+       partial_ibx_start $ctx, $ibx;
 }
 
 sub finalize_exact {
diff --git a/t/extmsg_event_step_regression.t b/t/extmsg_event_step_regression.t
new file mode 100644 (file)
index 0000000..941d11a
--- /dev/null
@@ -0,0 +1,70 @@
+#!perl -w
+# Copyright (C) all contributors <meta@public-inbox.org>
+# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
+use v5.12;
+use PublicInbox::TestCommon;
+use PublicInbox::Eml;
+use PublicInbox::IO qw(write_file);
+require_mods qw(-httpd v2 psgi);
+my $tmpdir = tmpdir;
+my $one = PublicInbox::Eml->new(<<'EOM');
+From: X <x@example.com>
+Subject: subj
+Date: Sat, 16 Jun 2007 17:33:53 +0100
+Message-ID: <681fb71bcf6@example.com>
+To: list@example.com
+Mime-Version: 1.0
+Content-Type: text/plain
+
+abc
+EOM
+my $two = PublicInbox::Eml->new(<<'EOM');
+From: X <x@example.com>
+Subject: Re: subj
+Date: Sat, 30 Jun 2007 18:56:36 +0100
+Message-ID: <eb1c75afc92@example.com>
+References: <681fb71bcf6@example.com>
+    <de34bbcfcf7@example.com>
+In-Reply-To: <de34bbcfcf7@example.com>
+To: Y <y@example.com>
+Cc: list@example.com
+MIME-Version: 1.0
+Content-Type: text/plain
+
+def
+EOM
+my %ibx = map {
+       $_ => create_inbox "v$_-event_step", version => $_,
+                       indexlevel => 'medium', sub {
+               my ($im, $ibx) = @_;
+               $im->add($one) or xbail 'add 1';
+               $im->add($two) or xbail 'add 2';
+       };
+} (1, 2);
+write_file '>', my $cfgpath = "$tmpdir/config", <<EOM;
+[publicinbox "list"]
+       address = list\@example.com
+        url = http://example.com/list
+       inboxdir = $ibx{1}->{inboxdir}
+[publicinbox "list2"]
+       address = list2\@example.com
+        url = http://example.com/list2
+       inboxdir = $ibx{2}->{inboxdir}
+EOM
+my $env = { TMPDIR => $tmpdir, PI_CONFIG => $cfgpath };
+my $client = sub {
+       my ($cb) = @_;
+       my $res = $cb->(GET('/list/de34bbcfcf7@example.com/'));
+       is $res->code, 300, 'v1 300';
+       $res = $cb->(GET('/list2/de34bbcfcf7@example.com/'));
+       is $res->code, 300, 'v2 300';
+};
+
+test_httpd($env, $client);
+{
+       require PublicInbox::WWW;
+       my $cfg = PublicInbox::Config->new($cfgpath);
+       my $www = PublicInbox::WWW->new($cfg);
+       test_psgi(sub { $www->call(@_) }, $client);
+}
+done_testing;