From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.52 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796120084; b=Tq1pJE4/AF2EP/3jvW1RjAq1wR+88Kaxbzxpgl21UcoSoENh1kTi1OQSOawQovxHfq7V gZyN6s2Lw4KtLyAAYpXfYz2qkL2HawU+jH3EK+OheyKtseIA8ni4OcKy/rGmVH5LM6CHn 2oTzGzfFarv4fZs9RrGrQ2qTQwfb64KgRA8jELQmFguKvbkYQCZXqe1VRtsIEN5kRPX/R 9PXfQ3Sn82apUECE8Vztr+BRKEDBSniljJdFP/kVKK1e4d8Ti5C3/agSFiS05zA0DU0dY 7dfFfwhZ1UqLQl8warbszFM6BzFQI1p1YeTLJJ4ZKjM6ou+hh0C0RqijOR1Qm+epc5w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796120084; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:Message-ID:Date: MIME-Version:User-Agent:Subject:To:Cc:References:Content-Language: From:In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=m+PeuH+9WXisNlsGIeS2DAAOHw6/CQZV/CLoAFcU9/U=; b=X00V0GVDMJKyF8CgOSUvWKk3nFh4GEMK2R82ps6UvETEM8YXW+LoaBWExmPojhPpaQ1Y zHi0CfMPuky7f+VTCQ472I+HG3jsrnazxb0pPTM/F2rGr3uWIg3omjsS1cXfSr8Gx1h7d sNA3ZgMh+fKBvtLsR0XuaCdaxxfpXBeIMBMhUoEKZGuwWZ5Sh4FTvM4bpjRFSZQ2RxCje vhurFbgDm1i9Bj8tVQizm8NhH9QA5k7ZxqV5OjkhNr2QnH0yw4iuqVokDy9nNXUzFw+AB 39PpG0POgIHE1TLOqusLHY60QDePc6i2taxNwMzpqQ4Yo0uE0Ert7lcJ1UiB5FO0Mfg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=qKZqg7TV; arc=none smtp.remote-ip=74.125.82.52 Received: from mail-dl1-f52.google.com (mail-dl1-f52.google.com [74.125.82.52]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 104E7606A31A for ; Tue, 1 Dec 2026 10:14:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 104E7606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=qKZqg7TV Received: by mail-dl1-f52.google.com with SMTP id a92af1059eb24-14394530ec6so7013936c88.1 for ; Tue, 01 Dec 2026 02:14:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796120083; x=1796724883; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=m+PeuH+9WXisNlsGIeS2DAAOHw6/CQZV/CLoAFcU9/U=; b=qKZqg7TVSxOUdH7kLmD9O0rQ6lZtZTVAuHUs3W5+lRYPoDuoRJAy/4KY+SUITLbHWX 5dejpDhUp2hNCqcp9MWBHrh5nxy+pddVUKRq5duoxfVbw5SnBC0Flpav6H7SWgQzkE8n jNxO5AolZP5K0EPEl/fhzEEkHvcxd6kiIqnn4obax4jq/EMfNuMMzKCfpB+sMmToJjSl aXyg2yVt7h+W3i8qrnARNd3+uGJDx7xQTbrnJMbEyzXtcDY4EvqmKy0avJLwHu7BjR/8 waAfBGTSzm/IgkQ9XrGqCL0b/1iiSNrAO1o0KATnnVWD/CEdyeVSXwo1cc2RS25bq+o9 d35g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796120083; x=1796724883; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=m+PeuH+9WXisNlsGIeS2DAAOHw6/CQZV/CLoAFcU9/U=; b=pqujr3nSraASCFpBNyE2ygqdr/RjMUyR3z2qF40v33V1P3DkVoribpU+hi/F+Ah5o9 4VW/HRce2AtmP9ZorYHkNX4elMn4w6ShAugzVLIA83sNbQhWw+yHieicAyQDS9pL2Y8c DqQrTjPBquU3PF9lY+y/2R9Bd6Ued+vRX7B1lQy2g6FC8/iZC7MrzRSHUOer5dm5JB4+ jY0sirQ+e/BNjrDup7vsa9T7cEjJWwFY0UW2n0PFU4Ywp+G6nH14U0QCqGmwa86j+hxs W3LWh4oXWpD6Evjdm8jZ+ntdrtBhfSjXNkXQFJglSM1s+7k9i72fmRtGt6dvt6ZObrGy oLEg== X-Gm-Message-State: APuU4Z9YsO1Q0Z6OjpWkW0cgSvGzg9t8UiyodoWL2FTK478wTFrNQbP3 W4dItcQAO7cN7B2xMUoXDdp/AGcRyEqmrmU8KAuC+/oEpzadIC8Vtr6mfVduoA== X-Gm-Gg: AZFdTZdsX3eYTUzJI0rbWtwZxseNOZr8rWJuZJ3OK/UqCYbKKljakw7L76Waokkvkef PpkjW/cQdlWK7PfCrGKaRl22Gr4PCr09gTMzgZEJqasV5ECOtSxUiuMecipftdAgiTwr9Wu9EE9 2og4fL0F6GNhUyy490XSsz/EH49Eb2aqZdGKcVbkFpUWFyAP/ezbUmAILeW/Pumwc3YhFmgEalA i/etex1VeHn78xEriO63m3Ryweo5UL9CeJWoLooym3KrC0WlY7NstjhcSUroRoLpjPzkQjfdz22 q1fksVE1NT8yxE6pjfC/rE2Aod+289h81fwGYQ+5es9URxkFIa5tdw4kUjYATBRqx3/dh4KuvyD bTqew5bt2UdFPOOqvL+IiJCL5Em58vKfwOJDhjUyHChg1ZzCBxuPQr1nsXXhIHYi7l8+7GQV3gw s2ozpKqAc1P/kfXfLOCUyj55z6EW0nUEnhO1u/v8UYXihJNec+wNVcbq7b1VyuStdwNKy2YJiUC ZL2h4cZ7YU3a7svsh9fBSz/J9NMCvMPKhVME5YpyiYYr8i8fso2qC8I9QJYy4qM8J+h5TVxnpvR JT0WOgfhLT+gv/M77KEKIxaQQ/kbsjmyjLGzixmmEQ== X-Received: by 2002:a05:7300:881a:b0:385:8aea:11bf with SMTP id 5a478bee46e88-3858aea13eamr41593085eec.41.1796120082980; Tue, 01 Dec 2026 02:14:42 -0800 (PST) Received: from [192.168.1.34] ([103.215.237.185]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-385646633d0sm184245608eec.3.2026.12.01.02.14.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 01 Dec 2026 02:14:42 -0800 (PST) Message-ID: <8427f816-2d04-460e-8909-f0740724f2a5@gmail.com> Date: Tue, 1 Dec 2026 15:44:39 +0530 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 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 1/2] test-lib: run EXPENSIVE tests one at a time To: Christian Couder Cc: Git mailing list , Harald Nordgren , Junio C Hamano , Patrick Steinhardt 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> Content-Language: en-US From: Kaartic Sivaraam In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 11/30/26 19:43, Christian Couder wrote: > >> +# This function takes care of cleaning up the lock we >> +# acquire in acquire_expensive_lock_. It is defined >> +# up here as we refer to it in die(). >> +release_expensive_lock_ () { >> + test -n "$have_expensive_lock_" || return 0 >> + rm -f "$expensive_lock_" >> + have_expensive_lock_= >> +} > > Something like the following would check whose lock it is before releasing it: > > ------------ > > # Remove the lock only if it still names $1 as its owner, so that > # a lock someone else has just taken is left alone. > remove_expensive_lock_owned_by_ () { > test "$(cat "$expensive_lock_" 2>/dev/null)" = "$1" && > rm -f "$expensive_lock_" > } > > release_expensive_lock_ () { > test -n "$have_expensive_lock_" || return 0 > remove_expensive_lock_owned_by_ $$ > have_expensive_lock_= > } > > ------------ > > This would limit the damage in the case (mentioned in the commit > message) where two waiters clearing the same stale lock at once let > two expensive tests run together: > > - waiters A and B both see a stale lock, > - A removes it and takes the lock, then B, which re-checked before A > removed it, removes A's lock and takes it too, > - both run, and when A finishes it deletes B's lock, so C starts while > B is still running. > > With the ownership check, A leaves B's lock alone, so the damage stays > at two tests instead of growing. > Interesting. That seems sensible. Will include this. >> + 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 > > Here we could both reuse the remove_expensive_lock_owned_by_() helper > and be a bit more verbose, for example: > Indeed. > # Another waiter may have taken it over since we > # looked, so only remove it if it is still the same. > if remove_expensive_lock_owned_by_ "$owner" > then > say >&3 "removing stale EXPENSIVE lock left by PID $owner" > fi > > The extra message might help when reading the logs of a run where a > script was killed. > Makes sense. Will include this too. >> + continue >> + fi >> + if test -z "$waited" >> + then >> + say >&3 "waiting for another EXPENSIVE test to finish" > > This and the message in expensive_lock_unavailable_() use `say >&3` > which prints to /dev/null when `-v` or `--verbose-log` is not passed. > > This is not an issue for CI runs as `--verbose-log` is used then. But > someone running tests locally without `-v` might wonder why their > local run is stuck. > Indeed. But I kind of assumed anyone wanting more diagnostics would run with '-v' anyways. > With Meson, or when running scripts or `prove` directly, nothing > cleans test-results/. So a lock left behind by SIGKILL (including the > OOM killer) can still be there days later. The same PID could then be > reused by a long-running process of the same user. This would result > in the script silently waiting forever. > > In such a case, printing something even if `-v` or `--verbose-log` is > not used, would likely make it much easier to understand what's going > on. > > So I would suggest sending this message, as well as the "running > anyway" and "removing stale" messages, to stderr instead. There are > only a few dozen EXPENSIVE tests, so this should not add much output. > The subtests in 2/2 that go through the stale lock removal would then > need to expect that message on stderr though. > > The message would also help even more if it included the holder's PID, > for example like "waiting for EXPENSIVE lock held by PID 1234". > Okay. I guess sending to stderr doesn't do us much harm either. I'll prefix it with a '#' to ensure it doesn't interfere with TAP. -- Sivaraam