Skip to content

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

Merged
derrickstolee merged 2 commits intomicrosoft:vfs-2.26.0from
derrickstolee:commit-graph-expire-fix
Apr 2, 2020
Merged

commit-graph: fix buggy --expire-time option#255
derrickstolee merged 2 commits intomicrosoft:vfs-2.26.0from
derrickstolee:commit-graph-expire-fix

Conversation

@derrickstolee
Copy link

@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>
@derrickstolee derrickstolee force-pushed the commit-graph-expire-fix branch from 32c55c0 to c7b4b07 Compare April 1, 2020 18:18
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.

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 force-pushed the commit-graph-expire-fix branch from c7b4b07 to 56a3126 Compare April 1, 2020 20:44
@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