From 18420b5f359def1afc569d3a42aab711cfc99acb Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 21 Oct 2025 03:03:46 +0000 Subject: [PATCH] extmsg: fix Message-ID search for non-xap_helper users 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 Link: https://public-inbox.org/meta/877bwva3s4.fsf@kyleam.com/ --- lib/PublicInbox/ExtMsg.pm | 8 ++-- t/extmsg_event_step_regression.t | 70 ++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 5 deletions(-) create mode 100644 t/extmsg_event_step_regression.t diff --git a/lib/PublicInbox/ExtMsg.pm b/lib/PublicInbox/ExtMsg.pm index 282db1d26..3e9b33a37 100644 --- a/lib/PublicInbox/ExtMsg.pm +++ b/lib/PublicInbox/ExtMsg.pm @@ -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 index 000000000..941d11ae8 --- /dev/null +++ b/t/extmsg_event_step_regression.t @@ -0,0 +1,70 @@ +#!perl -w +# Copyright (C) all contributors +# License: AGPL-3.0+ +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 +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 +Subject: Re: subj +Date: Sat, 30 Jun 2007 18:56:36 +0100 +Message-ID: +References: <681fb71bcf6@example.com> + +In-Reply-To: +To: Y +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", <{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; -- 2.47.3