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

commit-graph: fix buggy --expire-time option #255

Merged

Conversation

derrickstolee
Copy link
Collaborator

@derrickstolee derrickstolee commented Apr 1, 2020

This will need a change in microsoft/scalar and microsoft/vfsforgit to handle the correct input. It has never worked.

derrickstolee added a commit to derrickstolee/scalar that referenced this pull request Apr 1, 2020
See microsoft/git#255. For some reason I got myself confused as to
what --expire-time was for. The command-line interface says one thing
while the internal implementation does something different. Scalar
and VFS for Git were doing what the internal implementation was
expecting, but the option parsing was not properly reflecting the
data correctly.

This means that a lot of users have an excess of commit-graph files
in their object directories. This will quickly clean them all up.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Copy link
Member

@kewillford kewillford left a comment

Choose a reason for hiding this comment

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

LGTM one comment on another possible test case.

t/t5324-split-commit-graph.sh Outdated Show resolved Hide resolved
The use of 'touch -m' to modify a file's mtime is slightly less
portable than using our own 'test-tool chmtime'. The important
thing is that these pack-files are ordered in a special way to
ensure the multi-pack-index selects some as the "newer" pack-files
when resolving duplicate objects.

Reported-by: Jeff King <peff@peff.net>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
The commit-graph builtin has an --expire-time option that takes a
datetime using OPT_EXPIRY_DATE(). However, the implementation inside
expire_commit_graphs() was treating a non-zero value as a number of
seconds to subtract from "now".

Update t5323-split-commit-graph.sh to demonstrate the correct value
of the --expire-time option by actually creating a crud .graph file
with mtime earlier than the expire time. Instead of using a super-
early time (1980) we use an explicit, and recent, time. Using
test-tool chmtime to create two files on either end of an exact
second, we create a test that catches this failure no matter the
current time. Using a fixed date is more portable than trying to
format a relative date string into the --expiry-date input.

I noticed this when inspecting some Scalar repos that had an excess
number of commit-graph files. In Scalar, we were using this second
interpretation by using "--expire-time=3600" to mean "delete graphs
older than one hour ago" to avoid deleting a commit-graph that a
foreground process may be trying to load.

Also I noticed that the help text was copied from the --max-commits
option. Fix that help text.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
@derrickstolee derrickstolee merged commit e456d54 into microsoft:vfs-2.26.0 Apr 2, 2020
derrickstolee added a commit to microsoft/scalar that referenced this pull request Apr 2, 2020
Wow, this was really not working as expected.

See microsoft/git#255 for how broken the `--expire-time` argument was.

Fix this by using the fixed argument and passing a datetime instead of an offset by seconds. This will provide a longer window for old commit-graph files, but apparently we've been leaving turd files around for a long time without anyone noticing.
derrickstolee added a commit to microsoft/VFSForGit that referenced this pull request Apr 2, 2020
Wow, this was really not working as expected.

See microsoft/git#255 for how broken the `--expire-time` argument was.

Fix this by using the fixed argument and passing a datetime instead of an offset by seconds. This will provide a longer window for old commit-graph files, but apparently we've been leaving turd files around for a long time without anyone noticing.
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.

2 participants