From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 25B041F934 for ; Sat, 24 Apr 2021 22:42:59 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH] lei_saved_search: avoid reentrancy in ->is_dup Date: Sat, 24 Apr 2021 22:42:59 +0000 Message-Id: <20210424224259.980-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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;