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

Re: [PATCH v2] gc: reject if another gc is running, unless --force is given

From
Ramkumar Ramachandra <artagnon@gmail.com>
Date
Aug 3, 2013, 07:52 UTC
Message-ID
<CALkWK0k1vf_WE=pV5XTMAM6Ax6rL3sXu4qx_eyYwvWGsZjXgmA@mail.gmail.com>
In-Reply-To
<1375510890-4728-1-git-send-email-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy wrote:
Show 8 quoted lines
> This may happen when `git gc --auto` is run automatically, then the
> user, to avoid wait time, switches to a new terminal, keeps working
> and `git gc --auto` is started again because the first gc instance has
> not clean up the repository.
>
> This patch tries to avoid multiple gc running, especially in --auto
> mode. In the worst case, gc may be delayed 12 hours if a daemon reuses
> the pid stored in gc-%s.pid.
Definitely looks like a good solution. Thanks for this.
I'm currently on vacation, so can't apply and test: sorry.
> +       if (!force &&
> +           (fp = fopen(git_path("gc-%s.pid", utsname.nodename), "r")) != NULL &&
> +           !fstat(fileno(fp), &st) &&

It's open for a very short period of time, so lockfile (which we'd normally use) would probably be an overkill.

> +           time(NULL) - st.st_mtime <= 12 * 3600) {
Quick question: is this kind of file-lifetime used anywhere else in git.git?
> +                       if (auto_gc)
> +                               return 0; /* be quiet on --auto */
> +                       die(_("gc is already running"));
Nice.
Previous: Nguyễn Thái Ngọc DuyNext: Duy Nguyen
Message 3 of 20 in “gc: reject if another gc is running, unless --force is given”
  1. gc: reject if another gc is running, unless --force is givenNguyễn Thái Ngọc Duy, Aug 3, 2013
  2. gc: reject if another gc is running, unless --force is givenNguyễn Thái Ngọc Duy, Aug 3, 2013
  3. Ramkumar RamachandraAug 3, 2013
  4. Duy NguyenAug 3, 2013
  5. Johannes SixtAug 3, 2013
  6. Duy NguyenAug 3, 2013
  7. Johannes SixtAug 3, 2013
  8. gc: reject if another gc is running, unless --force is givenNguyễn Thái Ngọc Duy, Aug 5, 2013
  9. Junio C HamanoAug 5, 2013
  10. Ramkumar RamachandraAug 5, 2013
  11. Junio C HamanoAug 6, 2013
  12. Ramkumar RamachandraAug 6, 2013
  13. gc: reject if another gc is running, unless --force is givenNguyễn Thái Ngọc Duy, Aug 8, 2013
  14. Junio C HamanoAug 8, 2013
  15. Duy NguyenAug 9, 2013
  16. Junio C HamanoAug 9, 2013
  17. Andres PereraAug 9, 2013
  18. Junio C HamanoAug 9, 2013
  19. Duy NguyenAug 10, 2013
  20. Andreas SchwabAug 10, 2013

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.