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.