🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.git
Article #3320

[PATCH v4 2/2] maintenance: trace lock acquisition failures

#3320
From: Pushkar Singh
Date: Wed, 18 Nov 2026 19:07
75 lines
13489 bytes
When automatic or scheduled maintenance fails to acquire the
maintenance lock, emit a Trace2 data event describing the reason
for the failure.

The event uses the "maintenance" category and "lock/skip" key,
with the OS error reported via strerror(err).

This makes it easier to identify cases where automatic or
scheduled maintenance is repeatedly skipped due to lock
acquisition failures.

Signed-off-by: Pushkar Singh <pushkarkumarsingh1970@gmail.com>
---
 builtin/gc.c           |  4 ++++
 t/t7900-maintenance.sh | 29 +++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+)

diff --git a/builtin/gc.c b/builtin/gc.c
index d423b68cce..32d6f9c473 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -1413,6 +1413,10 @@ static int maintenance_run_tasks(struct maintenance_run_opts *opts,
 		 * another scheduled run is already running. Do not
 		 * report an error in either case.
 		 */
+		if (opts->auto_flag || opts->schedule)
+			trace2_data_string("maintenance", r, "lock/skip",
+					   strerror(err));
+
 		if (!opts->quiet) {
 			struct strbuf buf = STRBUF_INIT;
 
diff --git a/t/t7900-maintenance.sh b/t/t7900-maintenance.sh
index 4e519e4a5d..959c99a51f 100755
--- a/t/t7900-maintenance.sh
+++ b/t/t7900-maintenance.sh
@@ -423,6 +423,35 @@ test_expect_success 'scheduled maintenance skips with existing lock' '
 	test_path_is_file .git/objects/maintenance.lock
 '
 
+test_expect_success 'auto maintenance traces existing lock' '
+	test_when_finished "rm -f trace.txt .git/objects/maintenance.lock" &&
+	: >.git/objects/maintenance.lock &&
+	GIT_TRACE2_EVENT="$(pwd)/trace.txt" \
+		git maintenance run --auto --quiet &&
+	test_trace2_data maintenance lock/skip "File exists" <trace.txt &&
+	test_path_is_file .git/objects/maintenance.lock
+'
+
+test_expect_success 'scheduled maintenance traces existing lock' '
+	test_when_finished "rm -f trace.txt err .git/objects/maintenance.lock" &&
+	: >.git/objects/maintenance.lock &&
+	GIT_TRACE2_EVENT="$(pwd)/trace.txt" \
+		git maintenance run --schedule=hourly 2>err &&
+	test_must_be_empty err &&
+	test_trace2_data maintenance lock/skip "File exists" <trace.txt &&
+	test_path_is_file .git/objects/maintenance.lock
+'
+
+test_expect_success 'manual maintenance does not trace lock/skip' '
+	test_when_finished "rm -f trace.txt err .git/objects/maintenance.lock" &&
+	: >.git/objects/maintenance.lock &&
+	GIT_TRACE2_EVENT="$(pwd)/trace.txt" \
+		test_must_fail git maintenance run --quiet 2>err &&
+	test_must_be_empty err &&
+	! grep -e "\"category\":\"maintenance\",\"key\":\"lock/skip\"" trace.txt &&
+	test_path_is_file .git/objects/maintenance.lock
+'
+
 test_expect_success 'maintenance.loose-objects.auto' '
 	git repack -adk &&
 	GIT_TRACE2_EVENT="$(pwd)/trace-lo1.txt" \
-- 
2.53.0
Technical Details
Message-ID: <20261118190735.3928-3-pushkarkumarsingh1970@gmail.com>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!git+bounces-75728-linux-kernel-git=dewy.ru
References: <20261104173422.20725-1-pushkarkumarsingh1970@gmail.com> <20261118190735.3928-1-pushkarkumarsingh1970@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!git+bounces-75728-linux-kernel-git=dewy.ru
From: pushkarkumarsingh1970@gmail.com (Pushkar Singh)
Newsgroups: linux.kernel.git
Subject: [PATCH v4 2/2] maintenance: trace lock acquisition failures
Date: Wed, 18 Nov 2026 19:07:35 +0000
Organization: Usenet Network
Message-ID: <20261118190735.3928-3-pushkarkumarsingh1970@gmail.com>
References: <20261104173422.20725-1-pushkarkumarsingh1970@gmail.com>
 <20261118190735.3928-1-pushkarkumarsingh1970@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2674931"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:qIb8D35OHNtXVyFrsgReZaJthR0= sha256:jHORQai+8GVGSTs4WVFbuDI3Y45w68dbRE2PrMy5qzA=
	sha1:xlynFC3M9P5Pbe2VB97UQIjz75s= sha256:gFgDqSUNOFGcadlpD2lfubYcDMApdbILhKQVEfZHTYk=
List-ID: <git.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id E0983115389; Wed, 18 Nov 2026 22:08:41 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: 0.51
X-Spam-Status: No, score=0.51 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
	FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_SBL_CSS=3.558,
	SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001]
	autolearn=no autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id Uis4qYpgROjy;
	Wed, 18 Nov 2026 22:08:37 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=git+bounces-75728-linux-kernel-git=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 46271115379; Wed, 18 Nov 2026 22:08:28 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 8FD31120A14; Wed, 18 Nov 2026 19:08:21 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795028898;
	b=Xe43egMV8mTPtY+5xLd4CCl629hCYyMrHuuKqG+8y+H9fTyMcT+hn4Vl8cer9w0oN580
	 GMRCax+wfGVH0J/hkfCDS0wFoCBAx1bug4qHTPCzSmkLN+KGPFigSGeCZkie+V0L2rJF+
	 yOJ4jxRNAJoCfOdPR5GpgKdylqtF3x70KdNryaXP1w8Oz/7lBFDTqQNzrURkI77WkWLgN
	 +gvV/lneL3C7aEzEHC6NeHHXoROm733NFJp2wiT/Ru+Kc+YVvvH5wVmfCKKf899g4ab6b
	 /9NvM6qRBaBi2NqgkWtMtF8R7pOxej2VAdcnInS7gthoDM6wI/3Wep21DfndKB5Qriw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795028898;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
	 X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
	 Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:
	 References:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding;
	bh=qwp6PGSlhtBocTScbIJcs+9ZhJjGrMenbMoU4Cq/cK4=;
	b=whMnnRhJNrIBLDh0pTS4w8mCKB+o50T90D6tX+1g4yjErFjlyhWBbtcXBZ8HFCC68sZz
	 9YwvJ1sy9dPRW9T8MOF791N8eIyzK8Q813+Kl9mG2P+3BdbRHOMARSDEdtvoQ5/SXQFZG
	 eTt3olg6gzJUscq5eLOM2zKr0nEFAGYAHdkeIe6Dzhu5YQwMfu9y0Jfr8uNhqyCc5nqQT
	 b77xFelGTu1XRpBUT8hiBzK027ekuEtdVUcxhd6GWXFjPmSxAbjoPIDFq2m3yXtufBmLT
	 toPQlqpeWLB0Rx6jMJr6Sy5IqmkD38QpRdmAIFoa9LS9JVuAouLRW9YE4xD2gfUNxbg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b="W/x+jrL+";
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 9691560A2612;
	Wed, 18 Nov 2026 19:08:18 +0000 (UTC)
X-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=W/x+jrL+
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.178
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795028897;
	b=xh4xj6+lRNaXSn25W2s32ihTiAMbpdmsmFIKSyWoy9Q7DXdVeGLXH7sFZBdFo5qTnJcY
	 ltEz+DZuzkdJr/a9jj39CDyVlkTL0ZTMrK0wEk9QuIHPcG6fHLYIpMTBSGnBq9SYasxxM
	 xmU+epr7/DAgSEMHrwMZyphilcmypxLLpNbtfOTXATErQ2T4/2u76R7XYNDyWJRkQuipl
	 egwamHKg90pMg0RwE6DayKhbhSlGunhS6GiGGGRXy5ry0PG8yBoddxkn0gjqKqqgGRiLg
	 FN/76Dho4QPzEn2idXDrFtqF++V58osOmnhAIe6SJ1NUnyXU6N9hgbM45LbyIllKeIg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795028897;
	h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
	 X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:
	 Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version:
	 Content-Transfer-Encoding;
	bh=qwp6PGSlhtBocTScbIJcs+9ZhJjGrMenbMoU4Cq/cK4=;
	b=5ENnVkA4aFuVZ8SBGBHiSmX/JrzTb56CrxEVtmJ+yZcndhuLFLUY25lzKfH3vXU0+kyG
	 15P7JaoxUlxX5y+tVP1OQJGY1H3sru5ZmkD/iVp4pa/ill5+X6cq55haS+45U41Nvb/vX
	 Gn77Gjh22aFaL0RMJm9kGVaiFEeu3bRYUubB+Gf3OZfEWOqG7NrPYosfAd9fV1AgbU7zB
	 Y+73tu5o4o+JEi5ztbJ2sRYnQsSXZok3T3CGquQFykvTVkHJvpuzhclRzGNPQafJVlucO
	 fzk5eApxeQ4Smthjj0rhri8Cnur2OEclh/KFavFlrHTvyBgbIB1eqZb6G0d6JHKdSCA==
X-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="W/x+jrL+";
	arc=none smtp.remote-ip=74.125.82.178
X-Received: from mail-dy1-f178.google.com (mail-dy1-f178.google.com [74.125.82.178])
	(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 469E060A2600
	for <git@vger.kernel.org>; Wed, 18 Nov 2026 19:08:15 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 469E060A2600
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-dy1-f178.google.com with SMTP id 5a478bee46e88-382ecd5cf2cso155108eec.1
        for <git@vger.kernel.org>; Wed, 18 Nov 2026 11:08:15 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20260707; t=1795028894; x=1795633694; darn=vger.kernel.org;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:from:to:cc:subject:date
         :message-id:reply-to:content-type;
        bh=qwp6PGSlhtBocTScbIJcs+9ZhJjGrMenbMoU4Cq/cK4=;
        b=W/x+jrL+kdOt9bSHYPhIyL68Nm12Hexg3ZvnApCwR6LyV1zO7izEv7sasLvNI1SOa8
         7rVTfpb7Pl5KV3aWFB9pA+OltEeQbXEYmKaEzvnD+cAPZ8RczJQO3PguZbPgvPK/z2iY
         T3XgUJWLlTwTgg2jAj0ss4CA1Zf/6mkBCdeJE2rTo07HGsfFN2rB0C69MgWNv+zFs3ag
         Loo+lUKD/8+EAiCIupCvHipY6gDapzsy1MSdXcSVKam5vI/lO1Uga7oWSt8PcCYrpYNa
         l5DafQTvqS4f/PZutwcqjT10QF5gMq1ZzPjBogw0ivPBfzJujyKhtMDSGjnqXkZmHTuJ
         6U5g==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1795028894; x=1795633694;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from
         :to:cc:subject:date:message-id:reply-to:content-type;
        bh=qwp6PGSlhtBocTScbIJcs+9ZhJjGrMenbMoU4Cq/cK4=;
        b=yMTDWEHQxhSdgdmlYomJ1fCiUNNALrGG7d9TM0ExfpMnw9IPSMiDIt2r+T5fsDZ/0f
         rBq//KVpbXsOnIVeAcvVnvZZPoAuykcWW8uhwNUYGcGjaYs2ahgtpvgPxdilxn86jHm1
         XA04tO3MfMtprS/WFJbHb6M4NDs+wagP7nF03HVPIdMitQ0T/0S5RKyLE8gDr6c19JDM
         QRDLo9cXiVvcVL7FqlvJQoi8myf99pGRz4+MMTHbFnnVhXAC+c9rJw+H8R09oJH6r8ES
         CpjGrJ9byRcua9eYa++Xu0fFPdtaY78mRzhte8eXyAySe6gyBzcRCwz9Y6wyPVYOSj7I
         +reg==
X-Gm-Message-State: APuU4Z80YId4v39H82HxffEWdPLnO/gZ3xE+mw4wNVYtxrkReMhTWvMB
	BqPK3L7bFB5uzcJvtJrPjAVFON4s+3wcshgBwzF8/q1We5nFimf91m/Aa74QTA==
X-Gm-Gg: AZFdTZcx5zNPaDwxIYI6AAVHoGRui/zrZOrzXBxj7ZYyjTNIFA7M7MoQdvJ3GVAf6MB
	VTvrS1rtfwlkXcdn5vUDNFCgRFFIr/NIM4RoZrn/bU/He04zk+gvP1B/eYrDFfeCofUiF+c/Rq+
	Ty+JeKeIPaGUWOIdaIZ7Hixw3KkVwdwvc1JKdz/gzLpjxCQ4XhGHMkNv3gG3L0CI9qVdWvpXyx7
	Cy/grNWRHs6VWj4bj1YsH7jAwaHQGiiIYO2suCPmS7w+j2MEojg5EWxTc/x1mS2+akbah6gkhUd
	lD+cM3Uy6kDeuobXlFdbRyjARaA/XYph7N2vKw4TK80lo8zLfd02zKPSbRQ2Z7v/Tc2k4DyK0EO
	MekzdW4LYaICHuOhoJcWYeBbH8o+uIMa/jq08jY+j+n1UGjIKesjIjIQWHSdE3115LB17kDapXB
	hVc++ArQJpkkcLVeagAQnG2BT4Ff6WJ0benCVlE02nSGBFVbl2A/IzVsc5Niraif7f8v6J+uJF+
	X1myJIUbGCeI26R459MrQ0zRqokynmyRBrTS9rD10UTz4VjRfadFRKNrgR6v7chv2XqxmH7rE8A
	Ju5twY4tK2yZ7uWXGuF721V/iMa48XZgwUmkUwpQyroHvXMYGw==
X-Received: by 2002:a05:7300:b28:b0:369:f17d:efb with SMTP id 5a478bee46e88-383ee12cebdmr296626eec.10.1795028894160;
        Wed, 18 Nov 2026 11:08:14 -0800 (PST)
X-Received: from HP-V15.xu.edu.in ([125.22.10.135])
        by smtp.gmail.com with ESMTPSA id 5a478bee46e88-382a680032dsm9065155eec.10.2026.11.18.11.08.11
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Wed, 18 Nov 2026 11:08:13 -0800 (PST)
X-Cc: gitster@pobox.com,
	mail@thomasbachem.com,
	ps@pks.im,
	ttaylorr@openai.com,
	Pushkar Singh <pushkarkumarsingh1970@gmail.com>
X-Mailer: git-send-email 2.53.0
X-In-Reply-To: <20261118190735.3928-1-pushkarkumarsingh1970@gmail.com>
X-Mailing-List: git@vger.kernel.org
X-List-Post: <mailto:git@vger.kernel.org>
X-List-Help: <mailto:git+help@vger.kernel.org>
X-List-Subscribe: <mailto:git+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:git+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:git+owner@vger.kernel.org>
X-Precedence: list