Skip to content

Delete corrupt loose objects during LooseObjectsStep#1094

Merged
derrickstolee merged 11 commits intomicrosoft:masterfrom
derrickstolee:loose-check
May 7, 2019
Merged

Delete corrupt loose objects during LooseObjectsStep#1094
derrickstolee merged 11 commits intomicrosoft:masterfrom
derrickstolee:loose-check

Conversation

@derrickstolee
Copy link
Contributor

@derrickstolee derrickstolee commented May 2, 2019

If we have a corrupt loose object, the git pack-objects command will fail as it cannot put that object into a pack-file. This stops all future iterations of the LooseObjectsStep from succeeding, so users will be stuck in a bad situation.

  • Refactor WriteLooseObjectIds() to rely on a new LooseObjectsBatch() method.

  • On failure to create a pack, check all objects in the batch (using LooseObjectsBatch() and libgit2) and delete those that fail.

  • Start disposing the repo in the dehydrate verb for safety.

  • Create a functional test that verifies this behavior. Move the LooseObjectStepTests to have a new enlistment for each test, since we are messing with the object store. Part of the issue is that .NET doesn't allow us to move files that are marked as read-only, which becomes problematic as tests create pack-indexes and other files.

Resolves #1079

@derrickstolee
Copy link
Contributor Author

In addition to the functional test, I tried this on my machine. The object gets deleted as expected, along with additional logging.

Good news: if the corrupt loose object already exists in a pack, then the git prune-packed command will delete it without checking its contents.

@derrickstolee derrickstolee force-pushed the loose-check branch 2 times, most recently from dfd1cad to ae50663 Compare May 2, 2019 17:15
Copy link
Member

@jeschu1 jeschu1 left a comment

Choose a reason for hiding this comment

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

I think this is very close, few questions comments

@derrickstolee derrickstolee marked this pull request as ready for review May 3, 2019 13:02
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.

Looks good to me. Can we write some Unit tests for the new public methods that are being added?

Copy link
Member

@jrbriggs jrbriggs left a comment

Choose a reason for hiding this comment

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

Looks good, thanks.

@derrickstolee derrickstolee force-pushed the loose-check branch 7 times, most recently from 3c6a148 to b594a74 Compare May 7, 2019 11:22
We will need to enumerate a batch of loose objects independently
of writing them to a stream. Pull out the loop and consume it as
an enumerator instead.
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
@derrickstolee derrickstolee merged commit 6eec51c into microsoft:master May 7, 2019
derrickstolee added a commit that referenced this pull request May 9, 2019
… LooseObjectsStep

These are the same commits as #1094 and #1116, now targeting `releases/shipped`.

If we have a corrupt loose object, the `git pack-objects` command will fail as it cannot put that object into a pack-file. This stops all future iterations of the `LooseObjectsStep` from succeeding, so users will be stuck in a bad situation.

* Refactor `WriteLooseObjectIds()` to rely on a new `LooseObjectsBatch()` method.

* On failure to create a pack, check all objects in the batch (using `LooseObjectsBatch()` and libgit2) and delete those that fail.

* Start disposing the repo in the dehydrate verb for safety.

* Create a functional test that verifies this behavior. Move the `LooseObjectStepTests` to have a new enlistment for each test, since we are messing with the object store. Part of the issue is that .NET doesn't allow us to move files that are marked as read-only, which becomes problematic as tests create pack-indexes and other files.

Resolves #1079
@jrbriggs jrbriggs modified the milestones: Backlog, M153 May 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LooseObjectStep may fail due to corrupt loose object

5 participants