git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] maintenance: trace when auto maintenance skips due to lock

From
Patrick Steinhardt <ps@pks.im>
Date
Nov 2, 2026, 08:29 UTC
Message-ID
<auhJ0B_1__9z3DEC@pks.im>
In-Reply-To
<20261101105859.25579-2-pushkarkumarsingh1970@gmail.com>
On Sun, Nov 01, 2026 at 10:59:00AM +0000, Pushkar Singh wrote:
Show 10 quoted lines
> diff --git a/builtin/gc.c b/builtin/gc.c
> index 81cecf6b6c..e73d1f1d49 100644
> --- a/builtin/gc.c
> +++ b/builtin/gc.c
> @@ -1409,6 +1409,8 @@ static int maintenance_run_tasks(struct maintenance_run_opts *opts,
>  		 * recursive process stack. Do not report an error in
>  		 * that case.
>  		 */
> +		if (opts->auto_flag && errno == EEXIST)
> +			trace2_data_string("maintenance", r, "lock/skip", "exists");

So we now know to report failure when the lock exists already, but in any other case we don't log anything at all. But wouldn't the caller want to know when we failed because of for example EPERM, too, or because of any other error?

>  		if (!opts->auto_flag && !opts->quiet)
>  			warning(_("lock file '%s' exists, skipping maintenance"),
>  				lock_path);

It's quite curious that we only print a warning when `git maintenance run` has failed to acquire the lock instead of bubbling up an error. I would have expected that we:

  - Exit successfully but print a warning in the case where we are
    executed with "--auto".
  - Exit with an error code and print an error in the case where we
    execute without "--auto".

Silently swallowing the fact that we didn't do anything in the latter case certainly feels wrong to me. And git-gc(1) for example dies right away when the lock exists, so that to me is another indicator that we should follow and do the same for git-maintenance(1).

This is of course outside the scope of your patch series, but if you feel like it I think it could be easily fixed while at it in a second patch.

Thanks!
Patrick
Previous: Pushkar SinghNext: Pushkar Singh
Message 2 of 10 in “maintenance: trace when auto maintenance skips due to lock”
  1. maintenance: trace when auto maintenance skips due to lockPushkar Singh, Nov 1, 2026
  2. Patrick SteinhardtNov 2, 2026
  3. Pushkar SinghNov 2, 2026
  4. maintenance: improve handling of lock acquisition failuresPushkar Singh, Nov 2, 2026
  5. Patrick SteinhardtNov 2, 2026
  6. Pushkar SinghNov 3, 2026
  7. 0/2 maintenance: improve lock acquisition failure handlingPushkar Singh, Nov 4, 2026
  8. 1/2 maintenance: report lock acquisition failuresPushkar Singh, Nov 4, 2026
  9. 2/2 maintenance: trace lock acquisition failuresPushkar Singh, Nov 4, 2026
  10. Aniket GuptaNov 4, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.