Today, while pushing changes to the GitLab CE repo, we saw a warning:
(...)Total 18 (delta 17), reused 0 (delta 0)error: The last gc run reported the following. Please correct the root cause and remove gc.log.Automatic cleanup will not be performed until the file is removed.warning: There are too many unreachable loose objects; run 'git prune' to remove them.To git@gitlab.com:gitlab-org/gitlab-ce.git(...)
It looks like git gc sometimes can't handle unreachable objects. gc is executed automatically by some git commands and can be executed by our housekeeping feature. But in such situation it probably won't help.
My proposition is to add to the housekeeping - as an option (e.g. a checkbox in settings page) - execution of git prune inside of the repository. As for now we can do it only by logging on the server by SSH and executing it manually.
This of course entail an update in the gitlab-shell.
@jacobvosmaer I'm not sure if git gc without --no-prune does the same, what git prune does.
We didn't run housekeeping, @yorickpeterse juts executed git prune on the repository.
It looks like 'auto gc' is active.
I'm aware of this, but look at the message
error: The last gc run reported the following. Please correct the root cause and remove gc.log.Automatic cleanup will not be performed until the file is removed.warning: There are too many unreachable loose objects; run 'git prune' to remove them.
Automated gc run failed because of too many unreachable loose objects. And git also say to us: run 'git prune' to remove them. Not: run 'git gc'.
I think that running git prune is something that will be done really rarely, that's why I proposed to make this an option, not a normal housekeeping behavior.
Anyway - today execution of git prune fixed the problem. Maybe we should try to reproduce the problem and check if running only git gc would help. But I think it wouldn't (Please correct the root cause and remove gc.log).
@jacobvosmaer I've also read the #13524 (closed). Running git prune removed all unreachable objects... so it's exactly that, what shouldn't be done according to #13524 (closed). But - if I understand the warning properly - without this prune 'auto gc' wouldn't have any effect. Now it's more complicated than only allow to do git prune...
@tmaczukin I also don't understand what happened from the issue description. You say @yorickpeterse executed git prune? Where, on a gitlab.com server?
The error message you pasted talks about gc.log. That file is not in the gitlab-org/gitlab-ce.git bare repo on gitlab.com. So what is the error message talking about?
Yes. And also last gc run didn't finished because of There are too many unreachable loose objects; run 'git prune' to remove them. That's why I assumed, that git gc and git prune are doing different things. Other way git gc should handled the unreachable objects (and the warning says to me "no, use prune instead").
git gc by default includes git prune with a time based expiry rule: it prunes loose objects older than two weeks. In contrast, git gc --auto (which is run automatically after receiving a git push etc.) uses a count based expiry rule: if it counts too many loose objects it will warn (whine) about pruning. So if a repo accumulates a lot of loose objects in a period under two weeks, git gc --auto is bound to complain. A typical cause of loose objects is @yorickpeterse force pushing all the time .
Considering that we have now have our own version of git gc --auto I think we should disable it with git config. This is a manual step for source installations; for omnibus it can be automated easily.
We should also heed the warning and keep doing some sort of pruning. I think it would be best to go back to git gc (instead of the current git gc --no-prune) and have loose objects older than 2 weeks removed.