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

Re: [PATCH v3 7/7] run-command: fix detaching when running auto maintenance

From
Patrick Steinhardt <ps@pks.im>
Date
Aug 19, 2024, 09:04 UTC
Message-ID
<ZsMKpNMDTysNcreR@tanuki>
In-Reply-To
<20240819084614.GA2955268@coredump.intra.peff.net>
On Mon, Aug 19, 2024 at 04:46:14AM -0400, Jeff King wrote:
Show 36 quoted lines
> On Mon, Aug 19, 2024 at 08:17:22AM +0200, Patrick Steinhardt wrote:
> 
> > >   2. Having racy background maintenance doesn't seem great for test
> > >      robustness. At the very least, it might subject us to the "rm"
> > >      problems mentioned elsewhere, where we fail to clean up. Annotating
> > >      individual "git gc" or "git maintenance" calls with an extra
> > >      descriptor isn't too bad, but in this case it's all happening under
> > >      the hood via fetch. Is it a potential problem for every script,
> > >      then? If so, should we disable background detaching for all test
> > >      repos, and then let the few that want to test it turn it back on?
> > 
> > Might be a good idea to set `maintenance.autoDetach=false` globally,
> > yes. The only downside is of course that it wouldn't cause us to detect
> > failures like the above, where the concurrency itself causes failure.
> > 
> > Anyway, for now I'll:
> > 
> >   - Send a patch to fix the race in t7900.
> > 
> >   - Investigate the reftable concurrency issue.
> > 
> >   - _Not_ send a patch that sets `maintenance.autoDetach=false`.
> 
> That sounds like a good direction. I do suspect there are at least _two_
> races in t7900:
> 
>   1. the detached maintenance that we run explicitly, which causes the
>      "rm" cleanup to fail
> 
>   2. whatever earlier test is kicking off detached maintenance via "git
>      fetch", which is causing the reftable concurrency issue.
> 
> Fixing (1) should be easy (and it looks like you've already sent a
> series). Fixing the reftable code will stop us from segfaulting for (2),
> but I wonder if that detached maintenance might cause similar "rm" style
> problems elsewhere.

It certainly might. The only reason why I don't want to send that patch now is that it feels a bit too reactionary. We haven't had issues in the past with it to the best of my knowledge, even though it is an issue in theory.

We can certainly revisit that though if we see that it indeed is a more widespread issue.

Show 12 quoted lines
> > The last one requires a bit more discussion first, and we have been
> > running with `gc.autoDetach=true` implicitly in the past. Thinking a bit
> > more about it, the reason why the above bug triggers now is that
> > git-gc(1) itself runs git-pack-refs(1), but does that _synchronously_
> > before detaching itself. Now we detach at a higher level in the
> > hierarchy, which means that the previously-synchronous part now runs
> > asynchronously, as well.
> 
> That makes sense. I guess we've perhaps been doing background gc for a
> long time, then, just not in the refs? In practice most repos in the
> test suite aren't big enough to trigger auto-gc anyway, so it may only
> affect a handful of scripts.

Yup. We should expect this to work just fine, because it can trigger regardless of whether or not we run auto-compaction concurrently or not. After all, the reftable backend even performs auto-compaction after every write to the table, so any two concurrent writes may hit the bug without even invoking git-maintenance(1) at all.

Show 5 quoted lines
> Once the reftable issue is fixed, it's possible that the lingering
> detached processes don't cause a problem in practice (because they're
> not really writing much, and/or have finished by the time anybody else
> gets to cleanup), and we can just live with them. But I'm worried that
> sounds like wishful thinking. ;)

Could certainly be, yeah. I just want to focus on fixing the immediate issues before we jump to conclusions too fast.

Patrick
Previous: Jeff KingNext: Patrick Steinhardt
Message 77 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.