From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=202.12.124.151 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796123275; b=dA7ygEk76UelfbNE5trxvWcCHwRESYFPLOz6aUVvuqQJ9L74BkzeXmjUg9vXDY8fVE4c bixj9mQ8bGn+rXGvSSV7TNgnbRItXxhYKcNAyka6UHIycK07S9PfjiEKW2IhmO4Mwu7t4 xru9sBCp3jpkoe298AXIpiyp95oOnR9JK5LPkHOF/DSOZ26LhEhw68om1VNQ/3FlfLUXE CWMVrKyYQvkyCNcpCg6y8dhNPDymEbxbWmmusGFy5i/VyLV0OPUFiuPLlBi/zf5F6PTcY uR0RgCuruzdIdryQyZth8aGKyUO3gyDLPFyehtugVDOAFW+Ek/3inlBPdXoOdGRkiaw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796123275; h=DMARC-Filter:Received:Received:DKIM-Signature:DKIM-Signature: X-DKIM2-Info:DKIM2-Signature:X-DKIM2-Info:Message-Instance: X-ME-Sender:X-ME-Received:X-ME-Proxy-Cause:X-ME-Proxy:Feedback-ID: Received:Received:Date:From:To:Cc:Subject:Message-ID:References: MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=WvczyyGn6SJJ2kA7xl8ciPFsYD6sK8q8bti2LRzLOtA=; b=1OzVYl6Gpf7PhYRpOjMKqvks4hU3ARi+plq6E7cP9qjfLsP9lW8O2ywm9RkusNyMJZxY fPNUduJtEKdeqRRAlX7xTDVbrBpe66SijlEwSathDsmM31/zWRuoYHuVLjmCd1cYw+Lw6 QfdL1BZIpPEiK6Sr2N5k5+H9GbTLpNSCO21fjNNRPYbBW2Qv7US6lhAAcyKHgI4ccEQmZ SgAaWz0q1PVe2rLLAFi3H1bEAsZONFxbcpU8bY5IzONCy3aPowMfr2jrcx1U0WZHtP9jQ KKFYn8jUCV5TxT+trxVtz3FDglNmBbJJhnEqq03faTLywCIzS6TnednctviV00bV5Bg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass header.d=pks.im header.i=@pks.im header.a=rsa-sha256 header.s=fm3 header.b=Cmp1wKxt; dkim=pass header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=019k1yd5; arc=none smtp.remote-ip=202.12.124.151 Received: from fout-b8-smtp.messagingengine.com (fout-b8-smtp.messagingengine.com [202.12.124.151]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 87EA9606A31A for ; Tue, 1 Dec 2026 11:07:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 87EA9606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=pks.im header.i=@pks.im header.a=rsa-sha256 header.s=fm3 header.b=Cmp1wKxt; dkim=pass (2048-bit key, unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=019k1yd5 Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfout.stl.internal (Postfix) with ESMTP id 99A581D0053B for ; Tue, 1 Dec 2026 06:07:54 -0500 (EST) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-04.internal (MEProxy); Tue, 01 Dec 2026 06:07:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc:cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1796123274; x=1796209674; bh=WvczyyGn6S JJ2kA7xl8ciPFsYD6sK8q8bti2LRzLOtA=; b=Cmp1wKxtISlfxG1Iby1CT2n+1r GCM+9ItbtN8nJR0CNsGW5NI8OeWJdQjJRD9KQPQxJo4P0QiEjK5CpZnelmkHOSrX bco9/TtxOMvnFxlkiBoxUtwvroETG26IINMuDYdkGYDjJzHqq4CL0dEYo8EoPL6o NUjSXhiWrPhMBuuPPtpdyEp3e3iWq924RIjUKmIqUzKlecgAqXUFuF7WwfFOZFok qeSxgcXAtdoG63i8EDTRHoF0Ns6ZPb/EIdgdYHAa3nmycTN71om4BcG2WDeg6NWZ 5JKlhMRpeJ6Z/uNDT9MfELUoTXeNbdq/JpssPIzS3fD0RwHsMIeh+hqEUabg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1796123274; x=1796209674; bh=WvczyyGn6SJJ2kA7xl8ciPFsYD6sK8q8bti 2LRzLOtA=; b=019k1yd5FZP8qXUFcNW/cNhbMYSbPFmLlaXmRPD8wQAe+RAe7my YYao7EtkdiiGiG0iD9KtKL9y+Mt/hzlRZWIHhrkcKVxQv4azjs2bDtXpB6sk5Reh lyiurITKXDtANyu+HcjX1dQBc4tBoAVe1kDu5Ptl7v5G+qgW0tAvLo0boeAVEawy jxTYLPOdkT+PtJY7hI28ZJTvWaueyei1pgaU7WixkDBTPaA57ZjTF9AUh8CGuc6K H5uqoBYeCr6C1mC+OiS3NB8RPqdMjSgx4NvrDOJbRJvVIstTpRD5ruG0TtN7q4DX ZwAQtxNXkGmcmfGJ/g8g/zRC4XslhdVzsgg== X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=sign d=pks.im a=rsa-sha256; DKIM2-Signature: i=1; m=1; t=1796123274; d=pks.im; mf=PHBzQHBrcy5pbT4=; rt=PGdpdEB2Z2VyLmtlcm5lbC5vcmc+; s=fm3:rsa-sha256:Rurhc7mAc2f9QFCs/tu+2sc/JQXQYzRwaia6Z0SgfNQNJhP QyckswhmJAvX9FK/+RgjBBblf2OVyIupbQ6gQR5nVfwRJIj0u8uHdGlJngrsnhDa aimL/2pcGzEHgJJCvBOLaELu9ENcNqzAUg+8oM8aBNbhs5731jvxSeCJCeQO8h7U gsjrHJArNjnY+yBGr68xXW35y2dIv8jBouoVPakqQD+xuHxcDZ8T9w7lGCdYieZo WtTWXXRzN8sJHkSHAirUBuOFNnzQFkBeEHkhHgbOGQK0HvkEmKYV2brf4Z9F6iID AMGT0lJPINcq4dpTkRl9kbXRhb8umvwQM658HNg==; X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=mi-m=1; hc=12; hn=cc,content-disposition,content-type,date,feedback-id,from, in-reply-to,message-id,mime-version,references,subject,to; Message-Instance: m=1; h=sha256:NuiLNq4MYh9PRlwNwHGjWsGIWpP3CgN7RNHnaKimmWI=:Nl7xBDTWrILEL8LkYuiwkO79Fefm8pbLz8vtH2Uji+w=; X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTEfeKO6DqBpPl3qkZdNEN1YVOzeaEJmDA/5SuSQepqkht+jJmUJcRCRDzf2OHvB80 Z9Co3QDG2GW90Zl5QFdAcW9fu5sEd0GnPIIwCQZbbzyEJ/E++vRsDgGyfvZrBDikoHk8Zz ZlGXH4Km+YsdAXotpVkWXpVj/2Ev2FDA5xTnOCBepl8kRaR8b5ubK5Xh8RW7xK/V3CkCcK AC5iPeuO6ZZqdkZcUByqQUSshbqm6jwNbrKWmSWB7F2rNsQRDSP775aUjnCh+Q5iihx8/s Hk7dw6ksbJCyw7+yZKFxccDd1l3DjzkZZ8ii8riGW6ezr4f4yx7HoD+JtGRJpN1DzqE9lU YVw46I4pp95j/S8RmweGXCO0cn18S7rBz+7pscsJM7LrRulTmG2uH2YqKVZK5xNTyvqnBo Yx5tXoarbhQr3PexN0kGaW7//THJs7dp+iZcv93SOYPzWoQwsCD0NP36mdJJ3ZUfu65HjZ tLfIVOpsfHgA8yAWOLLEO0l0k/MMvWcN5BWAI5P6rYY8ZbY4b3BxbYRlZCk0L9D3xOv6lm FjgAy2B4lJXXPbag/nkC90rfVTuDwt1yEceU2q9WcRf9VPh1l05Mr7AAeFwyL93K9Lmzdd rGu4oNxT8eG8QMdVkN4crP2EsuJWbw+WnKF3NjauXcivJZX8ZL48Dl5HuvSA X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 1 Dec 2026 06:07:53 -0500 (EST) Received: by mail (OpenSMTPD) with ESMTPSA id 00d8940c (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 1 Dec 2026 11:07:51 +0000 (UTC) Date: Tue, 1 Dec 2026 12:07:49 +0100 From: Patrick Steinhardt To: Kaartic Sivaraam Cc: Git mailing list , Harald Nordgren , Junio C Hamano Subject: Re: [PATCH v4 1/2] test-lib: run EXPENSIVE tests one at a time Message-ID: References: <20261128-ks-ci-long-test-hang-fix-v4-0-f117badd2e13@gmail.com> <20261128-ks-ci-long-test-hang-fix-v4-1-f117badd2e13@gmail.com> <17e17015-53a8-4887-9891-7a7f2f16ea6c@gmail.com> X-Mailing-List: git@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <17e17015-53a8-4887-9891-7a7f2f16ea6c@gmail.com> On Tue, Dec 01, 2026 at 02:17:48PM +0530, Kaartic Sivaraam wrote: > On 12/1/26 12:52, Patrick Steinhardt wrote: > > > + > > > +acquire_expensive_lock_ () { > > > + local owner waited= tmp="$expensive_lock_.$$" misses=0 > > > + mkdir -p "$TEST_RESULTS_DIR" || > > > + { expensive_lock_unavailable_; return 0; } > > > + # The lock is a hard link to a file that already holds our PID, so > > > + # it never exists without its owner recorded in it. Remove any > > > + # $tmp left by a dead process with our PID first: it may still be > > > + # linked to that process's lock, which writing to it would empty. > > > + rm -f "$tmp" > > > > Nit: it is expected that in most cases this won't do anything, so in the > > expected common case we'll see an error message. Do we want to silence > > this? > > > > I guess that was mostly done to keep things consistent as we pretty much > silence everything in this function. So, I tend to prefer keeping the '-f' > on this one too. Oh, the "-f" should be kept indeed. But shouldn't it be `2>/dev/null`? Ah, no, rm(1) doesn't actually complain in case the target path does not exist. I thought it did. One week off and I've already forgotten everything. > > > + misses=0 > > > + owner=$(cat "$expensive_lock_" 2>/dev/null) > > > + # A lock carrying our own PID was left by a dead holder whose > > > + # PID we were given again; we know we do not hold it. > > > + if test -n "$owner" && > > > + { test "$owner" = $$ || ! kill -0 "$owner" 2>/dev/null; } > > > + then > > > + # The holder was killed without releasing the lock. > > > + # > > > + # Another waiter may have taken it over since we > > > + # looked, so only remove it if it is still the same. > > > + if test "$(cat "$expensive_lock_" 2>/dev/null)" = "$owner" > > > + then > > > + rm -f "$expensive_lock_" > > > + fi > > > > I feel like re-checking the lock owner is kind of pointless here. The > > check doesn't fix the race, but it suggests it to the reader. And that > > is overall fine, because the intent now is to fail in a way that we > > prefer to run the test instead of blocking forever. > > > > But it raises the question why we even bother to check again. To me it > > only causes puzzlement. > > > > The re-check is present in order to prevent a specific race scenario pointed > out by Junio: > > > * T1 holds $expensive_lock_, finishes its last EXPENSIVE test, > > calls release_expensive_lock_ (rm -rf "$expensive_lock_"), and > > exits. > > > > * Waiter T2 read owner=$(cat "$expensive_lock_/pid" 2>/dev/null) > > (obtaining T1's PID) just before T1 removed the directory. > > > > * Waiter T3 runs mkdir "$expensive_lock_", succeeds, writes T3's > > PID to pid, and begins its EXPENSIVE test. > > > > * T2 now checks test -n "$owner" && ! kill -0 "$owner" 2>/dev/null > > against T1's exited PID, finds that T1 is gone, runs rm -rf > > "$expensive_lock_", which deletes T3's active lock. It loops, > > succeeds on mkdir "$expensive_lock_", and runs its EXPENSIVE test > > concurrently with T3. > > > It talks about the variant that created directories but it applies for the > current linking variant also. > > If we could improve the comment above the relevant code in someway, do let > me know. It tries to convey it but I unfortunately couldn't get what detail > it is missing. But the race isn't fully fixed, is it? You have simply narrowed the race window, but the race itself still exists between `test $(cat "$expensive_lock_" = "$owner")` and the `rm -f`, doesn't it? Patrick