Git development
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Adrian Ratiu <adrian.ratiu@collabora.com>
Cc: Junio C Hamano <gitster@pobox.com>,
	rsbecker@nexbridge.com, git@vger.kernel.org
Subject: [PATCH] t5401: test SIGPIPE with parallel hooks
Date: Wed, 8 Apr 2026 13:30:32 -0400	[thread overview]
Message-ID: <20260408173032.GB2293804@coredump.intra.peff.net> (raw)
In-Reply-To: <87v7e11j4q.fsf@collabora.com>

On Wed, Apr 08, 2026 at 08:01:25PM +0300, Adrian Ratiu wrote:

> > It sounds sensible, but a standalone fix early before 2.54 final, as
> > the problem and the fix shown by Peff here looked correct, without
> > waiting for NonStop may be simpler to work with.  Then, rebuild
> > parallel series on top of the 'master' that has the fix applied,
> > perhaps?
> 
> Yes, that is the path forward now that Randall also confirmed the fix
> works on NonStop (btw thank you Randall). :)
> 
> Just waiting for Peff to tell me if he wants to send it himself.

I just sent out the fix patch, which should be good for 2.54. Here's the
test patch, which I hope you'll include when re-rolling the parallel
series (either as-is, or if you prefer it can be moved to another script
where we're doing other parallel hook tests).

It would be nice to refer to the fix commit using its id, but we won't
know what it is until Junio applies it. :) So once that happens it might
be worth tweaking the commit message.

-- >8 --
Subject: t5401: test SIGPIPE with parallel hooks

We recently fixed a bug where a hook that caused us to get SIGPIPE would
accidentally trigger the run_processes_parallel() cleanup handler,
killing the child processes.

For a single hook, this meant killing the already-exited hook. This case
was triggered by our tests, but was only a problem on some platforms.

But if you have multiple hooks running in parallel, this causes a
problem everywhere, since one hook failing to read its input would take
down all hooks. Now that we have parallel hook support, we can add a
test for this case. It should pass already, due to the existing fix.

Signed-off-by: Jeff King <peff@peff.net>
---
 t/t5401-update-hooks.sh | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/t/t5401-update-hooks.sh b/t/t5401-update-hooks.sh
index 44ec875aef..f727b5d545 100755
--- a/t/t5401-update-hooks.sh
+++ b/t/t5401-update-hooks.sh
@@ -139,4 +139,42 @@ test_expect_success 'pre-receive hook that forgets to read its input' '
 	git push ./victim.git "+refs/heads/*:refs/heads/*"
 '
 
+test_expect_success 'hooks in parallel that do not read input' '
+	# Add this to our $PATH to avoid having to write the whole trash
+	# directory into our config options, which would require quoting.
+	mkdir bin &&
+	PATH=$PWD/bin:$PATH &&
+
+	write_script bin/hook-fast <<-\EOF &&
+	# This hook does not read its input, so the parent process
+	# may see SIGPIPE if it is not ignored. It should happen
+	# relatively quickly.
+	exit 0
+	EOF
+
+	write_script bin/hook-slow <<-\EOF &&
+	# This hook is slow, so we expect it to still be running
+	# when the other hook has exited (and the parent has a pipe error
+	# writing to it).
+	#
+	# So we want to be slow enough that we expect this to happen, but not
+	# so slow that the test takes forever. 1 second is probably enough
+	# in practice (and if it is occasionally not on a loaded system, we
+	# will err on the side of having the test pass).
+	sleep 1
+	exit 0
+	EOF
+
+	git init --bare parallel.git &&
+	git -C parallel.git config hook.fast.command "hook-fast" &&
+	git -C parallel.git config hook.fast.event pre-receive &&
+	git -C parallel.git config hook.fast.parallel true &&
+	git -C parallel.git config hook.slow.command "hook-slow" &&
+	git -C parallel.git config hook.slow.event pre-receive &&
+	git -C parallel.git config hook.slow.parallel true &&
+	git -C parallel.git config hook.jobs 2 &&
+
+	git push ./parallel.git "+refs/heads/*:refs/heads/*"
+'
+
 test_done
-- 
2.54.0.rc1.274.g1f8c576c50


  reply	other threads:[~2026-04-08 17:30 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-07 23:37 Help needed on 2.54.0-rc0 t5301.13 looping rsbecker
2026-04-08  5:20 ` Jeff King
2026-04-08  5:43   ` Jeff King
2026-04-08 11:53     ` Adrian Ratiu
2026-04-08 15:44       ` rsbecker
2026-04-08 15:52       ` rsbecker
2026-04-08 15:55       ` rsbecker
2026-04-08 16:53       ` Junio C Hamano
2026-04-08 16:58         ` rsbecker
2026-04-08 17:01         ` Adrian Ratiu
2026-04-08 17:30           ` Jeff King [this message]
2026-04-08 15:50   ` Junio C Hamano
2026-04-08 16:26     ` Adrian Ratiu
2026-04-08 17:20       ` [PATCH] run_processes_parallel(): fix order of sigpipe handling Jeff King
2026-04-08 17:59         ` Junio C Hamano
2026-04-08 20:54           ` Junio C Hamano
2026-04-08 23:42             ` Jeff King
2026-04-09 13:40               ` Junio C Hamano

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260408173032.GB2293804@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=adrian.ratiu@collabora.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=rsbecker@nexbridge.com \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox