Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GIT Packfile claims to have more objects, inaccessable

I am running into multiple errors about my packfile that seem pretty insidious, this is a pretty scary deal since this is a live site and am not sure how to handle it, maybe someone can talk me through it, here's whats going on.

It seems that I have a missing object, and also the count of my packfile is bad?

remote: Counting objects: 25733, done.
remote: Compressing objects: 100% (12458/12458), done.
remote: Total 19185 (delta 6914), reused 17995 (delta 6535)

Receiving objects: 100% (19185/19185), 1.69 GiB | 465 KiB/s, done.
Resolving deltas: 100% (6914/6914), completed with 1058 local objects.

error: packfile .git/objects/pack/pack-1f0643b00b9c201338b7f1365ef188ef682a6a9e.pack claims to have 19185 objects while index indicates 20243 objects
error: packfile .git/objects/pack/pack-1f0643b00b9c201338b7f1365ef188ef682a6a9e.pack cannot be accessed
error: packfile .git/objects/pack/pack-1f0643b00b9c201338b7f1365ef188ef682a6a9e.pack claims to have 19185 objects while index indicates 20243 objects
error: packfile .git/objects/pack/pack-1f0643b00b9c201338b7f1365ef188ef682a6a9e.pack cannot be accessed
error: packfile .git/objects/pack/pack-1f0643b00b9c201338b7f1365ef188ef682a6a9e.pack claims to have 19185 objects while index indicates 20243 objects
error: packfile .git/objects/pack/pack-1f0643b00b9c201338b7f1365ef188ef682a6a9e.pack cannot be accessed

error: unable to find e17196d88ae91dea07b4d61716b91dac581fb131

error: packfile .git/objects/pack/pack-1f0643b00b9c201338b7f1365ef188ef682a6a9e.pack claims to have 19185 objects while index indicates 20243 objects
error: packfile .git/objects/pack/pack-1f0643b00b9c201338b7f1365ef188ef682a6a9e.pack cannot be accessed

fatal: object e17196d88ae91dea07b4d61716b91dac581fb131 not found

EDIT Another one seems to have sprouted up, so now I have ....

.git/objects/pack/pack-1f0643b00b9c201338b7f1365ef188ef682a6a9e.pack 
.git/objects/pack/pack-931e28ca404e28040a10085dd1534ef12cf18c6d.pack

I've tried copying those both up past www-root, and removing them, and am now running git-gc and am going to try refetching origin with git fetch origin

git-gc now returns

bad sha1 file: .git/objects/05/.a2e1939ce5a53d5ec7c3cacc4df97acd09c6af.hdgIVe
bad sha1 file: .git/objects/80/.1a75684e9d869e9ed7c1ded674c55caa17c524.YUr1Yu
bad sha1 file: .git/objects/8c/.7e8381b3e0d0a1f1d4fa328f0dda0a1dbd814a.L0255H
bad sha1 file: .git/objects/c5/.32926ac2d67785cb8580b885ac3d3fd7075f57.rDsW4H
Removing stale temporary file .git/objects/pack/tmp_pack_jnP5qn
like image 697
ehime Avatar asked Jul 09 '12 19:07

ehime


People also ask

How do I reduce the size of a git pack?

When you do a Git clone, it will create a copy of the whole repository, this includes the pack file as this is part of the repo too. The only way to reduce the size of the pack file will be by removing contents from your repo.

Can I delete git pack files?

What you are looking to do is called rewriting history, and it involved the git filter-branch command. This will remove all references to the files from the active history of the repo. Next step, to perform a GC cycle to force all references to the file to be expired and purged from the packfile.

What is in Git objects pack?

These are, in essence, multiple objects stored with an efficient delta compression scheme as a single compressed file. You can think of it as akin to a Zip file of multiple objects, which Git can extract efficiently when needed. Pack files are stored in the . git/objects/pack/ directory.

What is pack file in .GIT folder?

The packfile is a single file containing the contents of all the objects that were removed from your filesystem. The index is a file that contains offsets into that packfile so you can quickly seek to a specific object.


1 Answers

As mentioned in "Problems with corrupt git repo", and its associated discussion:

Many of these objects are then packed together into a packfile to save space. You corrupted these packfiles by changing their content – even worse: changing the length of their content.
git fsck does not actually fix anything about a git repository, it just checks for errors and reports them.
git unpack-objects on the other hand is able to unpack as much as possible from a corrupted packfile, but you will still have errors in your repo, as git fsck --full will report.
See "How to fix a broken repository?" or "How to remove all broken refs from a repository?".


Note that with Git 2.4.3 (June 2015), there is no more warning packfile .git/objects/pack/pack-xxx.pack cannot be accessed.
That allows to focus on the actual errors only.

See commit 319b678 [31 Mar 2015] by Jeff King (peff).
(Merged by Junio C Hamano -- gitster -- in commit 3c91e99, 05 Jun 2015)

As usual with Peff, the explanation is enlightening:

sha1_file: squelch "packfile cannot be accessed" warnings

When we find an object in a packfile index, we make sure we can still open the packfile itself (or that it is already open), as it might have been deleted by a simultaneous repack.
If we can't access the packfile, we print a warning for the user and tell the caller that we don't have the object (we can then look in other packfiles, or find a loose version, before giving up).

The warning we print to the user isn't really accomplishing anything, and it is potentially confusing to users.

In the normal case, it is complete noise; we find the object elsewhere, and the user does not have to care that we racily saw a packfile index that became stale. It didn't affect the operation at all.

A possibly more interesting case is when we later can't find the object, and report failure to the user. In this case the warning could be considered a clue toward that ultimate failure. But it's not really a useful clue in practice. We wouldn't even print it consistently (since we are racing with another process, we might not even see the .idx file, or we might win the race and open the packfile, completing the operation).

This patch drops the warning entirely (not only from the fill_pack_entry site, but also from an identical use in pack-objects).
If we did find the warning interesting in the error case, we could stuff it away and reveal it to the user when we later die() due to the broken object. But that complexity just isn't worth it.


And with Git 2.22.1 (Q3 2019), "git update-server-info" used to leave stale packfiles in its output, which has been corrected.

See commit e941c48 (23 May 2019) by Eric Wong (ele828).
Helped-by: Jeff King (peff).
(Merged by Junio C Hamano -- gitster -- in commit 776d668, 25 Jul 2019)

server-info: do not list unlinked packs

Having non-existent packs in objects/info/packs causes dumb HTTP clients to abort.

v2: use single loop with ALLOC_GROW as suggested by Jeff King


With Git 2.35 (Q1 2022), there is new interface into the tmp-objdir API to help in-core use of the quarantine feature.

See commit ecd81df, commit b3cecf4 (06 Dec 2021) by Neeraj Singh (neerajsi-msft).
(Merged by Junio C Hamano -- gitster -- in commit 0dc90d9, 03 Jan 2022)

tmp-objdir: new API for creating temporary writable databases

Based-on-patch-by: Elijah Newren
Signed-off-by: Neeraj Singh
Reviewed-by: Elijah Newren

The tmp_objdir API provides the ability to create temporary object directories, but was designed with the goal of having subprocesses access these object stores, followed by the main process migrating objects from it to the main object store or just deleting it.
The subprocesses would view it as their primary datastore and write to it.

Here we add the tmp_objdir_replace_primary_odb function that replaces the current process's writable "main" object directory with the specified one.
The previous main object directory is restored in either tmp_objdir_migrate or tmp_objdir_destroy.

For the --remerge-diff usecase, add a new will_destroy flag in struct object_database`` to mark ephemeral object databases that do not require fsync durability.

Add 'git prune'(man) support for removing temporary object databases, and make sure that they have a name starting with tmp_ and containing an operation-specific name.

The prune message goes from:

Removing stale temporary file ...

To:

Removing stale temporary directory ...
like image 170
VonC Avatar answered Nov 09 '22 11:11

VonC