When does Stash run Git GC?

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

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.

 

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.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

1,764 views 1 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you