Clean up old .nfsXXX files after 'git gc' and 'git repack'
When using GitLab with NFS we can end up with leftover .nfsXXX files after git gc or git repack ran on a busy repository. From what I understand this is because of how NFS implements traditional Unix file deletion semantics (if a file is unlinked while open, it should remain available until all processes that have the file open closed it). This leads to wasted space: at worst, a full copy of the repository.
I think the best thing we can do about this is to traverse the current repository (as you do with find) in GitGarbageCollectWorker and remove .nfsXXX files older than, say, 24 hours.
Such a find run in the directory would not take too long; there are less than ~256 (00 through ff for loose objects, packs) subdirectories in objects/. It is harder to put an upper bound on the refs directory because its contents are formed by whatever refs (tags, branches) the user created in the repository. But ref files are very small we could consider not cleaning up .nfsXXX files in there at all.
So I think we should probably just go with some find objects -mtime YYY -delete incantation in GitGarbageCollectWorker.
cc @yorickpeterse because he likes find
cc @pcarranza because he likes disk space
cc @chriscool because I am making claims about Git internals