From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH] git: fix cat_async_retry
Date: Tue, 11 Apr 2023 11:23:50 +0000 [thread overview]
Message-ID: <20230411112350.297099-1-e@80x24.org> (raw)
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);
reply other threads:[~2023-04-11 11:23 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230411112350.297099-1-e@80x24.org \
--to=e@80x24.org \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).