Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

When does Stash run Git GC?

Balázs Szakmáry
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 13, 2015

Does Stash ever run Git GC proactively? Ideally, I would like Stash to run Git GC regularly during the night, to avoid it being triggered automatically by Git after a push in the middle of the workday. Is there some kind of mechanism for this? If yes, how do I configure when and how often the GC's should happen?

Bonus question: what happens when a Git GC is running and someone does a clone/pull?

Side note: I tried this plugin, the only thing it does is throw HTTP 405 errors.

1 answer

3 votes
Stefan Saasen
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 19, 2015

For repositories that don't have forks we rely on git running auto gc on push. That doesn't necessarily mean git gc will actually run, git uses a heuristic to decide whether gc is necessary (the repository has either 6700 loose objects or 50 pack files. The number of loose objects is estimated by counting how many objects are in objects/17).

For forks we disable auto gc and run GC ourselves if necessary. We use a similar heuristic and also check when the last gc happened. This is also triggered by pushes but will run in the background.

Ideally, I would like Stash to run Git GC regularly during the night, to avoid it being triggered automatically by Git after a push in the middle of the workday. Is there some kind of mechanism for this?

Therefore there is no built in mechanism to schedule garbage collection. It'd be good if you could raise an issue (https://jira.atlassian.com/browse/STASH) that details why you want this and what problems you are currently experiencing that could be solved by this.

Bonus question: what happens when a Git GC is running and someone does a clone/pull?

Clones are not affected when git gc is being executed (but see below). Pack files are not being mutated, new pack file is being generated and gc deletes the old packs afterwards. Git relies on the Posix "delete on last close" semantics which in this case lets git delete unused packs without impacting clone operations that currently read from a pack file that was deleted so the clone can finish without problems.

With shared file storage this may potentially cause a problem as NFS doesn't give you proper "delete on last close" semantics across multiple NFS clients. So far that hasn't been an actual problem anyone has encountered, but we're pondering a number of potential solutions to address this if it ever becomes a problem.

 

Balázs Szakmáry
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 19, 2015

Thanks for the detailed answer! What about pushes while the GC is running? I think they need to wait for the GC to be complete.

Balázs Szakmáry
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 19, 2015

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events