8000 Fix shallow root maintenance during fetch by kcsaul · Pull Request #6846 · libgit2/libgit2 · GitHub
[go: up one dir, main page]

Skip to content

Fix shallow root maintenance during fetch #6846

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 10, 2024

Conversation

kcsaul
Copy link
Contributor
@kcsaul kcsaul commented Jul 7, 2024

Fixes issue where the shallow roots array size wasn't being copied as part of preparing to perform a fetch.

This resulted in the shallow roots file being removed unexpectedly at the end of the fetch, even though there's still one or more shallow root commits as they weren't included/ancestors of the branches/commits fetched, which subsequently led to invalid/missing object errors.

@ethomson
Copy link
Member
ethomson commented Jul 8, 2024

Hmm, sounds right, but it looks like you've uncovered a memory leak. 🤔

@kcsaul kcsaul force-pushed the fix/setup_shallow_roots branch from 93071a0 to a5f3380 Compare July 9, 2024 06:58
@kcsaul kcsaul force-pushed the fix/setup_shallow_roots branch from a5f3380 to 9e40c13 Compare July 9, 2024 11:25
@kcsaul
Copy link
Contributor Author
kcsaul commented Jul 9, 2024

@ethomson - Could you please have another look at this?

I believe the memory leak you'd spotted was a knock-on impact of an existing test failing due to the fix. I've updated the online::shallow::shorten_four test to reflect what git does when fetching with depth 5, and then 4 afterwards. It doesn't actually remove the original set of shallow roots, presumably because they're not traversed on the server during the subsequent fetch. It's not until git gc is run the unreachable shallow roots are removed.

Now that I've realized where to add a new test - I've added one to prove existing shallow roots will be preserved during fetch for an unrelated branch, and that they'll be removed as expected during subsequent fetches.

Outstanding/failing test appears to be one of the flaky network tests.

@ethomson
Copy link
Member

I believe the memory leak you'd spotted was a knock-on impact of an existing test failing due to the fix. I've updated the online::shallow::shorten_four test to reflect what git does when fetching with depth 5, and then 4 afterwards. It doesn't actually remove the original set of shallow roots, presumably because they're not traversed on the server during the subsequent fetch. It's not until git gc is run the unreachable shallow roots are removed.

Ah, that makes sense. Perfect, thanks so much. 🙏

@ethomson ethomson merged commit db5b9f5 into libgit2:main Jul 10, 2024
18 of 19 checks passed
@ethomson ethomson added the bug label Sep 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0