Skip to content
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

git pull: release file handles to pack files before fetching #3415

Merged
merged 2 commits into from Sep 8, 2021

Conversation

dscho
Copy link
Member

@dscho dscho commented Sep 7, 2021

This is a tentative fix for #3336.

@dscho dscho force-pushed the release-packs-before-fetching branch 2 times, most recently from bf8fab1 to 48566dd Compare September 7, 2021 12:23
@@ -713,6 +713,7 @@ static void close_commit_graph_one(struct commit_graph *g)
if (!g)
return;

clear_commit_graph_data_slab(&commit_graph_data_slab);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@derrickstolee could I ask you to look over this change, to see whether it is sound?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. If we are closing the commit-graph, then the graph might change when we reopen it, leading to different graph_pos values.

@@ -713,6 +713,7 @@ static void close_commit_graph_one(struct commit_graph *g)
if (!g)
return;

clear_commit_graph_data_slab(&commit_graph_data_slab);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. If we are closing the commit-graph, then the graph might change when we reopen it, leading to different graph_pos values.

The slab has information about the commit graph. That means that it is
meaningless (and even misleading) when the commit graph was closed.

This seems not to matter currently, but we're about to fix a
Windows-specific bug where `git pull` does not close the object store
before fetching (risking that an implicit auto-gc fails to remove the
now-obsolete pack file(s)), and once we have that bug fix in place, it
does matter: after that bug fix, we will open the object store, do some
stuff with it, then close it, fetch, and then open it again, and do more
stuff. If we close the commit graph without releasing the corresponding
slab, we're hit by a symptom like this in t5520.19:

	BUG: commit-reach.c:85: bad generation skip 9223372036854775807
	> 3 at 5cd378271655d43a3b4477520014f02213ad1546

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
On Windows, files cannot be removed nor renamed if there are still
handles held by a process. To remedy that, we try to release all open
handles to any `.pack` file before e.g. repacking (which would want to
remove the original `.pack` file(s) after it is done).

Since the `read_cache_unmerged()` and/or the `get_oid()` call in `git
pull` can cause `.pack` files to be opened, we need to release the open
handles before calling `git fetch`: the latter process might want to
spawn an auto-gc, which in turn might want to repack the objects.

This commit is similar in spirit to 5bdece0 (gc/repack: release
packs when needed, 2018-12-15).

This fixes git-for-windows#3336.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
@dscho dscho force-pushed the release-packs-before-fetching branch from 48566dd to 0e956ae Compare September 8, 2021 07:40
@dscho dscho merged commit 82a7ae1 into git-for-windows:main Sep 8, 2021
git-for-windows-ci pushed a commit that referenced this pull request Sep 8, 2021
git pull: release file handles to pack files before fetching
git-for-windows-ci pushed a commit that referenced this pull request Sep 8, 2021
git pull: release file handles to pack files before fetching
git-for-windows-ci pushed a commit that referenced this pull request Sep 8, 2021
git pull: release file handles to pack files before fetching
@dscho dscho added this to the Next release milestone Sep 8, 2021
dscho added a commit to git-for-windows/build-extra that referenced this pull request Sep 8, 2021
A bug where Git's garbage collection during a
`git pull` failed to delete obsolete files [was
fixed](git-for-windows/git#3415).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit that referenced this pull request Sep 8, 2021
git pull: release file handles to pack files before fetching
dscho added a commit that referenced this pull request Sep 9, 2021
git pull: release file handles to pack files before fetching
dscho added a commit that referenced this pull request Sep 9, 2021
git pull: release file handles to pack files before fetching
dscho added a commit that referenced this pull request Sep 9, 2021
git pull: release file handles to pack files before fetching
git-for-windows-ci pushed a commit that referenced this pull request Sep 10, 2021
git pull: release file handles to pack files before fetching
dscho added a commit that referenced this pull request Sep 13, 2021
git pull: release file handles to pack files before fetching
dscho added a commit that referenced this pull request Sep 13, 2021
git pull: release file handles to pack files before fetching
dscho added a commit that referenced this pull request Sep 13, 2021
git pull: release file handles to pack files before fetching
git-for-windows-ci pushed a commit that referenced this pull request Sep 13, 2021
git pull: release file handles to pack files before fetching
git-for-windows-ci pushed a commit that referenced this pull request Sep 14, 2021
git pull: release file handles to pack files before fetching
git-for-windows-ci pushed a commit that referenced this pull request Sep 15, 2021
git pull: release file handles to pack files before fetching
@dscho dscho deleted the release-packs-before-fetching branch October 4, 2021 13:12
dscho added a commit that referenced this pull request Oct 4, 2021
git pull: release file handles to pack files before fetching
dscho added a commit that referenced this pull request Oct 4, 2021
git pull: release file handles to pack files before fetching
dscho added a commit that referenced this pull request Oct 4, 2021
git pull: release file handles to pack files before fetching
git-for-windows-ci pushed a commit that referenced this pull request Oct 6, 2021
git pull: release file handles to pack files before fetching
dscho added a commit that referenced this pull request Oct 7, 2021
git pull: release file handles to pack files before fetching
dscho added a commit that referenced this pull request Oct 22, 2021
git pull: release file handles to pack files before fetching
git-for-windows-ci pushed a commit that referenced this pull request Oct 24, 2021
git pull: release file handles to pack files before fetching
git-for-windows-ci pushed a commit that referenced this pull request Oct 24, 2021
git pull: release file handles to pack files before fetching
git-for-windows-ci pushed a commit that referenced this pull request Oct 24, 2021
git pull: release file handles to pack files before fetching
git-for-windows-ci pushed a commit that referenced this pull request Oct 25, 2021
git pull: release file handles to pack files before fetching
git-for-windows-ci pushed a commit that referenced this pull request Oct 25, 2021
git pull: release file handles to pack files before fetching
git-for-windows-ci pushed a commit that referenced this pull request Oct 25, 2021
git pull: release file handles to pack files before fetching
git-for-windows-ci pushed a commit that referenced this pull request Oct 25, 2021
git pull: release file handles to pack files before fetching
dscho added a commit that referenced this pull request Oct 26, 2021
git pull: release file handles to pack files before fetching
git-for-windows-ci pushed a commit that referenced this pull request Oct 28, 2021
git pull: release file handles to pack files before fetching
git-for-windows-ci pushed a commit that referenced this pull request Oct 28, 2021
git pull: release file handles to pack files before fetching
git-for-windows-ci pushed a commit that referenced this pull request Oct 28, 2021
git pull: release file handles to pack files before fetching
git-for-windows-ci pushed a commit that referenced this pull request Oct 28, 2021
git pull: release file handles to pack files before fetching
git-for-windows-ci pushed a commit that referenced this pull request Oct 28, 2021
git pull: release file handles to pack files before fetching
dscho added a commit that referenced this pull request Oct 29, 2021
git pull: release file handles to pack files before fetching
git-for-windows-ci pushed a commit that referenced this pull request Oct 29, 2021
git pull: release file handles to pack files before fetching
dscho added a commit that referenced this pull request Oct 29, 2021
git pull: release file handles to pack files before fetching
git-for-windows-ci pushed a commit that referenced this pull request Oct 29, 2021
git pull: release file handles to pack files before fetching
dscho added a commit that referenced this pull request Oct 29, 2021
git pull: release file handles to pack files before fetching
git-for-windows-ci pushed a commit that referenced this pull request Oct 29, 2021
git pull: release file handles to pack files before fetching
git-for-windows-ci pushed a commit that referenced this pull request Oct 29, 2021
git pull: release file handles to pack files before fetching
git-for-windows-ci pushed a commit that referenced this pull request Oct 29, 2021
git pull: release file handles to pack files before fetching
git-for-windows-ci pushed a commit that referenced this pull request Oct 29, 2021
git pull: release file handles to pack files before fetching
git-for-windows-ci pushed a commit that referenced this pull request Oct 29, 2021
git pull: release file handles to pack files before fetching
git-for-windows-ci pushed a commit that referenced this pull request Oct 29, 2021
git pull: release file handles to pack files before fetching
dscho added a commit that referenced this pull request Nov 1, 2021
git pull: release file handles to pack files before fetching
dscho added a commit that referenced this pull request Nov 4, 2021
git pull: release file handles to pack files before fetching
dscho added a commit that referenced this pull request Nov 4, 2021
git pull: release file handles to pack files before fetching
dscho added a commit that referenced this pull request Nov 10, 2021
git pull: release file handles to pack files before fetching
dscho added a commit that referenced this pull request Nov 16, 2021
git pull: release file handles to pack files before fetching
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants