user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
* [PATCH] lei_saved_search: avoid reentrancy in ->is_dup
@ 2021-04-24 22:42 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2021-04-24 22:42 UTC (permalink / raw)
  To: meta

Use a separate git process when calling xoids_for to prevent
reentrancy in ->is_dup.  Reentrancy happens since LeiToMail will
call ->is_dup when inside callbacks when writing mail.

This fixes --dedupe=mid test failures in t/lei-q-save.t

I could only reproduce this consistently on a uniprocessor VM.
"schedtool -a 0x1 -e ..." could not reproduce the problem on
2 and 4-core systems.
---
 lib/PublicInbox/LeiSavedSearch.pm | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/PublicInbox/LeiSavedSearch.pm b/lib/PublicInbox/LeiSavedSearch.pm
index af864a50..682a43e8 100644
--- a/lib/PublicInbox/LeiSavedSearch.pm
+++ b/lib/PublicInbox/LeiSavedSearch.pm
@@ -6,6 +6,7 @@ package PublicInbox::LeiSavedSearch;
 use strict;
 use v5.10.1;
 use parent qw(PublicInbox::Lock);
+use PublicInbox::Git;
 use PublicInbox::OverIdx;
 use PublicInbox::LeiSearch;
 use PublicInbox::Config;
@@ -224,11 +225,13 @@ sub prepare_dedupe {
 
 sub over { $_[0]->{oidx} } # for xoids_for
 
-sub git { $_[0]->{ale}->git }
+# don't use ale->git directly since is_dup is called inside
+# ale->git->cat_async callbacks
+sub git { $_[0]->{git} //= PublicInbox::Git->new($_[0]->{ale}->git->{git_dir}) }
 
 sub pause_dedupe {
 	my ($self) = @_;
-	$self->{ale}->git->cleanup;
+	git($self)->cleanup;
 	my $lockfh = delete $self->{lockfh}; # from lock_for_scope_fast;
 	my $oidx = delete($self->{oidx}) // return;
 	$oidx->commit_lazy;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-04-24 22:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-24 22:42 [PATCH] lei_saved_search: avoid reentrancy in ->is_dup Eric Wong

user/dev discussion of public-inbox itself

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/meta
	git clone --mirror http://czquwvybam4bgbro.onion/meta
	git clone --mirror http://hjrcffqmbrq6wope.onion/meta
	git clone --mirror http://ou63pmih66umazou.onion/meta

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 meta meta/ https://public-inbox.org/meta \
		meta@public-inbox.org
	public-inbox-index meta

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.mail.public-inbox.meta
	nntp://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.mail.public-inbox.meta
	nntp://ie5yzdi7fg72h7s4sdcztq5evakq23rdt33mfyfcddc5u3ndnw24ogqd.onion/inbox.comp.mail.public-inbox.meta
	nntp://4uok3hntl7oi7b4uf4rtfwefqeexfzil2w6kgk2jn5z2f764irre7byd.onion/inbox.comp.mail.public-inbox.meta
	nntp://news.gmane.io/gmane.mail.public-inbox.general
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for project(s) associated with this inbox:

	https://80x24.org/public-inbox.git

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git