Retrying requests on alternates changing was causing inflight requests to get lost due to {inflight} getting clobbered by batch_prepare.
Unfortunately, reproducing this is difficult without mocking ->alternates_changed. SearchIdx now avoids calling ->batch_prepare directly and relies on more common API functions. Fixes: 65db62eb006f ("git: use --batch-command in git 2.36+ to save processes") --- lib/PublicInbox/Git.pm | 11 +++++------ lib/PublicInbox/SearchIdx.pm | 6 +++++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm index e35d5277..f153237b 100644 --- a/lib/PublicInbox/Git.pm +++ b/lib/PublicInbox/Git.pm @@ -229,8 +229,7 @@ sub cat_async_retry ($$) { delete $self->{inflight}; cleanup($self); - $self->{inflight} = $inflight; - batch_prepare($self); + batch_prepare($self, $inflight); my $buf = ''; for (my $i = 0; $i < @$inflight; $i += 3) { $buf .= "$inflight->[$i]\n"; @@ -312,8 +311,8 @@ sub cat_async_wait ($) { } } -sub batch_prepare ($) { - my ($self) = @_; +sub batch_prepare ($$) { + my ($self, $inflight) = @_; check_git_exe(); if ($GIT_VER ge BATCH_CMD_VER) { _bidi_pipe($self, qw(batch-command in out pid err_c)); @@ -321,7 +320,7 @@ sub batch_prepare ($) { } else { _bidi_pipe($self, qw(batch in out pid)); } - $self->{inflight} = []; + $self->{inflight} = $inflight; } sub _cat_file_cb { @@ -581,7 +580,7 @@ sub cat_async_begin { my ($self) = @_; cleanup($self) if $self->alternates_changed; die 'BUG: already in async' if $self->{inflight}; - batch_prepare($self); + batch_prepare($self, []); } sub cat_async ($$$;$) { diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm index 496cea05..3415cce4 100644 --- a/lib/PublicInbox/SearchIdx.pm +++ b/lib/PublicInbox/SearchIdx.pm @@ -1074,7 +1074,11 @@ sub _index_sync { my $ibx = $self->{ibx}; local $self->{current_info} = "$ibx->{inboxdir}"; $self->{batch_bytes} = $opt->{batch_size} // $BATCH_BYTES; - $ibx->git->batch_prepare; + + if ($X->{CLOEXEC_UNSET}) { + $ibx->git->cat_file($tip); + $ibx->git->check($tip); + } my $pr = $opt->{-progress}; my $sync = { reindex => $opt->{reindex}, -opt => $opt, ibx => $ibx }; my $quit = quit_cb($sync);