Don't keep the index repository open long term #847
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
After deploying #813 there was a big change in the number of used file descriptors. This is likely a result of libgit2/libgit2#2758 given that #813 changed behaviour to keep the index repository open instead of just opening it when needed.
Given how long that
libgit2
issue and the PR fixing it have been open, it seems unlikely to be fixed soon. It would probably be ok to have all the packfiles open all the time, except based on this comment when running a concurrentgit gc
the garbage collected packfiles will not be closed, so there will be a constant slow fd leak until the service is restarted (which you can see in the graph below).This PR changes behaviour back to match the old setup, only opening the repository when needed, and sticks some more context on related errors just in case.