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

Re: [PATCH 3/3] builtin/maintenance: fix loose objects task emitting pack hash

From
Patrick Steinhardt <ps@pks.im>
Date
Aug 20, 2024, 07:39 UTC
Message-ID
<ZsRIHS0mFZaRHFVc@tanuki>
In-Reply-To
<20240819102602.GA2961332@coredump.intra.peff.net>
On Mon, Aug 19, 2024 at 06:26:02AM -0400, Jeff King wrote:
Show 43 quoted lines
> On Mon, Aug 19, 2024 at 11:26:06AM +0200, Patrick Steinhardt wrote:
> 
> > > Am I misreading the documentation? The entry for maintenance.autoDetach
> > > on 'next' says:
> > > 
> > >   If unset, the value of `gc.autoDetach` is used as a fallback. Defaults
> > >   to true if both are unset, meaning that the maintenance process will
> > >   detach.
> > 
> > You've omitted the important part:
> > 
> > 	Many Git commands trigger automatic maintenance after they have
> > 	written data into the repository. This boolean config option
> > 	controls whether this automatic maintenance shall happen in the
> > 	foreground or whether the maintenance process shall detach and
> > 	continue to run in the background.
> > 
> > The `maintenance.autoDetach` setting only impacts auto-maintentance as
> > run via `run_auto_maintenance()`. The `--auto` flag is somewhat
> > orthogonal: it asks the git-maintenance(1) job to do nothing in case the
> > repository is already optimal.
> 
> Ah. I naively assumed that they did so by passing the "--auto" flag. But
> I see now that the caller actually checks the config and passes
> "--detach" or not.
> 
> That seems kind of unfriendly to scripted porcelains which want to
> invoke it, since they have to reimplement that logic. The idea of "git
> gc --auto" was that it provided a single API for scripts to invoke,
> including respecting the user's config. Now that "maintenance --auto"
> has taken that over, I'd have expected it to do the same.
> 
> To be clear, I don't feel all that strongly about it, but I'm not sure I
> buy the argument that it is orthogonal, or that here:
> 
> > For git-gc(1) we indeed did tie the `--auto` flag to backgrounding,
> > which is somewhat nonsensical. There are usecases where you may want to
> > pass `--auto`, but still have it run in the foreground. That's why we
> > handle this differently for git-maintenance(1), which requires you to
> > pass an explicit `--detach` flag.
> 
> we couldn't just patch "--no-detach" for cases where you want to be sure
> it is in the foreground.

We certainly could. But honestly, your scripted use case you mention above is even more of an argument why we shouldn't do it, in my opinion. We have long had the stance that the behaviour of plumbing tools should _not_ be impacted by the user configuration. And detaching based on some config to me very much sounds like the exact opposite.

Mind you, we are all quite used to `git gc --auto` detaching. But if I were new to the project, I'd find it quite surprising that it may or may not detach if all I want it to do is to decide for itself whether it needs to garbage collect or not. It is much more straight forward and way less surprising for a script writer to use `--detach` if they want the script to detach, because now the command does what they want without them having to worry about the user's config.

Show 11 quoted lines
> > Also, we cannot change the behaviour of git-maintenance(1) retroactively
> > to make `--auto` detach. While it already essentially did detach for
> > git-gc(1), that was a bug. E.g. when running as part of the scheduler,
> > we'd always have detached and thus ended up with a bunch of concurrent
> > git-gc(1) processes. So even though it does make sense for the scheduler
> > to use `--auto`, it wouldn't want the process to detach.
> 
> Backwards compatibility is a more compelling argument here, if we've had
> "maintenance --auto" that didn't ever detach (though it sounds like it
> did, via gc, anyway). But yes, one kicked off from a scheduler should be
> using --no-detach, I'd think.

Yes, we did, but as mentioned it was buggy. Once the scheduler kicks off, you'd now have N git-gc(1) processes all running in parallel to each other. With N being large you will certainly face some issues. You also lose the exit code, which is another issue.

But as you said, you could make the scheduler pass `--no-detach`. In fact, the first versions of this patch series were using your approach, where I changed `git maintenance run --auto` to detach based on the config. But after some thought (and after seeing the negative fallout that this had on our test suite) I decided to throw this approach away because it just didn't feel right to me.

> Like I said, I don't feel strongly enough to work on any changes here.
> I'd hoped to never think about repository maintenance ever again. So you
> can take these as just impressions of a (relatively) clueful user seeing
> it for the first time. ;)

I certainly appreciate the discussion, thanks for chiming in! I'm still not convinced that we should continue to couple auto-maintenance and backgrounding to each other. In my opinion, this behaviour was a mistake in the past and continues to surprise now, too. Making it an explicit option feels more natural to me.

That being said, when others feel strongly about this, as well, then I'm of course happy to adapt.

Patrick
Previous: Jeff KingNext: Junio C Hamano
Message 73 of 79 in “builtin/maintenance: fix auto-detach with non-standard tasks”
  1. 0/7 builtin/maintenance: fix auto-detach with non-standard tasksPatrick Steinhardt, Aug 13, 2024
  2. 1/7 config: fix constness of out parameter for `git_config_get_expiry()`Patrick Steinhardt, Aug 13, 2024
  3. 2/7 builtin/gc: refactor to read config into structurePatrick Steinhardt, Aug 13, 2024
  4. James LiuAug 15, 2024
  5. Patrick SteinhardtAug 15, 2024
  6. Derrick StoleeAug 15, 2024
  7. 3/7 builtin/gc: fix leaking config valuesPatrick Steinhardt, Aug 13, 2024
  8. James LiuAug 15, 2024
  9. Patrick SteinhardtAug 15, 2024
  10. Derrick StoleeAug 15, 2024
  11. 4/7 builtin/gc: stop processing log file on signalPatrick Steinhardt, Aug 13, 2024
  12. James LiuAug 15, 2024
  13. 5/7 builtin/gc: add a `--detach` flagPatrick Steinhardt, Aug 13, 2024
  14. 6/7 builtin/maintenance: add a `--detach` flagPatrick Steinhardt, Aug 13, 2024
  15. 7/7 builtin/maintenance: fix auto-detach with non-standard tasksPatrick Steinhardt, Aug 13, 2024
  16. Phillip WoodAug 13, 2024
  17. Patrick SteinhardtAug 13, 2024
  18. Phillip WoodAug 13, 2024
  19. Patrick SteinhardtAug 14, 2024
  20. Phillip WoodAug 14, 2024
  21. Patrick SteinhardtAug 15, 2024
  22. James LiuAug 15, 2024
  23. Patrick SteinhardtAug 15, 2024
  24. Derrick StoleeAug 15, 2024
  25. James LiuAug 15, 2024
  26. 0/7 builtin/maintenance: fix auto-detach with non-standard tasksPatrick Steinhardt, Aug 15, 2024
  27. 2/7 builtin/gc: refactor to read config into structurePatrick Steinhardt, Aug 15, 2024
  28. 1/7 config: fix constness of out parameter for `git_config_get_expiry()`Patrick Steinhardt, Aug 15, 2024
  29. 6/7 builtin/maintenance: add a `--detach` flagPatrick Steinhardt, Aug 15, 2024
  30. 5/7 builtin/gc: add a `--detach` flagPatrick Steinhardt, Aug 15, 2024
  31. Junio C HamanoAug 15, 2024
  32. Junio C HamanoAug 15, 2024
  33. Patrick SteinhardtAug 16, 2024
  34. 4/7 builtin/gc: stop processing log file on signalPatrick Steinhardt, Aug 15, 2024
  35. 7/7 run-command: fix detaching when running auto maintenancePatrick Steinhardt, Aug 15, 2024
  36. Junio C HamanoAug 15, 2024
  37. Patrick SteinhardtAug 16, 2024
  38. 3/7 builtin/gc: fix leaking config valuesPatrick Steinhardt, Aug 15, 2024
  39. Derrick StoleeAug 15, 2024
  40. Junio C HamanoAug 15, 2024
  41. Patrick SteinhardtAug 16, 2024
  42. 0/7 builtin/maintenance: fix auto-detach with non-standard tasksPatrick Steinhardt, Aug 16, 2024
  43. 1/7 config: fix constness of out parameter for `git_config_get_expiry()`Patrick Steinhardt, Aug 16, 2024
  44. 2/7 builtin/gc: refactor to read config into structurePatrick Steinhardt, Aug 16, 2024
  45. 3/7 builtin/gc: fix leaking config valuesPatrick Steinhardt, Aug 16, 2024
  46. 4/7 builtin/gc: stop processing log file on signalPatrick Steinhardt, Aug 16, 2024
  47. 5/7 builtin/gc: add a `--detach` flagPatrick Steinhardt, Aug 16, 2024
  48. 6/7 builtin/maintenance: add a `--detach` flagPatrick Steinhardt, Aug 16, 2024
  49. Jeff KingAug 17, 2024
  50. Jeff KingAug 17, 2024
  51. Patrick SteinhardtAug 19, 2024
  52. 7/7 run-command: fix detaching when running auto maintenancePatrick Steinhardt, Aug 16, 2024
  53. Jeff KingAug 17, 2024
  54. Patrick SteinhardtAug 19, 2024
  55. 0/3 Fixups for git-maintenance(1) testsPatrick Steinhardt, Aug 19, 2024
  56. 1/3 t7900: fix flaky test due to leaking background jobPatrick Steinhardt, Aug 19, 2024
  57. Jeff KingAug 19, 2024
  58. Patrick SteinhardtAug 19, 2024
  59. Jeff KingAug 19, 2024
  60. Patrick SteinhardtAug 19, 2024
  61. 2/3 t7900: exercise detaching via trace2 regionsPatrick Steinhardt, Aug 19, 2024
  62. Jeff KingAug 19, 2024
  63. Patrick SteinhardtAug 19, 2024
  64. Junio C HamanoAug 21, 2024
  65. Patrick SteinhardtAug 22, 2024
  66. Junio C HamanoAug 22, 2024
  67. 3/3 builtin/maintenance: fix loose objects task emitting pack hashPatrick Steinhardt, Aug 19, 2024
  68. Jeff KingAug 19, 2024
  69. Patrick SteinhardtAug 19, 2024
  70. Jeff KingAug 19, 2024
  71. Patrick SteinhardtAug 19, 2024
  72. Jeff KingAug 19, 2024
  73. Patrick SteinhardtAug 20, 2024
  74. Junio C HamanoAug 20, 2024
  75. Junio C HamanoAug 19, 2024
  76. Jeff KingAug 19, 2024
  77. Patrick SteinhardtAug 19, 2024
  78. Patrick SteinhardtAug 19, 2024
  79. Patrick SteinhardtAug 19, 2024

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.