Internal Server Error 500: GetBranchCommit: packfile not found #4038

Closed
opened 2025-11-02 05:35:15 -06:00 by GiteaMirror · 7 comments
Owner

Originally created by @robertschulze on GitHub (Oct 1, 2019).

  • Gitea version (or commit ref): 4.0 (1.10.0+dev-334-gc6fb7fe27)
  • Git version: 2.23.0.windows.1 (portable)
  • Operating system: Windows 7
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:

Description

When trying to open one of my repos in the Gitea web interface, I receive an Internal Server Error 500. Checking the log file, I see:

.../xorm/session_raw.go:76:queryRows() [I] [SQL] SELECT `id`, `uid`, `repo_id` FROM `star` WHERE `uid`=? AND `repo_id`=? LIMIT 1 []interface {}{1, 2} - took: 0s
...ules/context/repo.go:606:func1() [E] GetBranchCommit: packfile not found

(I removed the timestamp)

Screenshots

info

Originally created by @robertschulze on GitHub (Oct 1, 2019). <!-- NOTE: If your issue is a security concern, please send an email to security@gitea.io instead of opening a public issue --> <!-- 1. Please speak English, this is the language all maintainers can speak and write. 2. Please ask questions or configuration/deploy problems on our Discord server (https://discord.gg/gitea) or forum (https://discourse.gitea.io). 3. Please take a moment to check that your issue doesn't already exist. 4. Please give all relevant information below for bug reports, because incomplete details will be handled as an invalid report. --> - Gitea version (or commit ref): 4.0 (1.10.0+dev-334-gc6fb7fe27) - Git version: 2.23.0.windows.1 (portable) - Operating system: Windows 7 - Database (use `[x]`): - [ ] PostgreSQL - [ ] MySQL - [ ] MSSQL - [X] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [X] No - [ ] Not relevant - Log gist: ## Description When trying to open one of my repos in the Gitea web interface, I receive an Internal Server Error 500. Checking the log file, I see: ``` .../xorm/session_raw.go:76:queryRows() [I] [SQL] SELECT `id`, `uid`, `repo_id` FROM `star` WHERE `uid`=? AND `repo_id`=? LIMIT 1 []interface {}{1, 2} - took: 0s ...ules/context/repo.go:606:func1() [E] GetBranchCommit: packfile not found ``` (I removed the timestamp) ## Screenshots ![info](https://user-images.githubusercontent.com/13728481/65938276-d714db00-e422-11e9-8119-5eb957bd4d74.png) <!-- **If this issue involves the Web Interface, please include a screenshot** -->
GiteaMirror added the type/bugissue/workaround labels 2025-11-02 05:35:15 -06:00
Author
Owner

@robertschulze commented on GitHub (Oct 2, 2019):

Can I provide anything else to help in/advance the analysis of the error?

@robertschulze commented on GitHub (Oct 2, 2019): Can I provide anything else to help in/advance the analysis of the error?
Author
Owner

@pampersrocker commented on GitHub (Oct 2, 2019):

I've had just the same error.
git fsck and git fsck --full on the repository stored in gitea did not report anything broken and the error persists after a git repack.
The error message seems to come from go-git: eb243ba9a5/storage/filesystem/dotgit/dotgit.go (L268)

Pushing another commit to the default branch on my repository opens the repository again, but looking at the commit history does produce a 500 error due to

...uters/repo/commit.go:62:Commits() [E] CommitsByRange: packfile not found

For me this looks to be a bug in go-git not handling some case in a commit properly (as git itself does not report any errors)

@pampersrocker commented on GitHub (Oct 2, 2019): I've had just the same error. `git fsck` and `git fsck --full` on the repository stored in gitea did not report anything broken and the error persists after a `git repack`. The error message seems to come from go-git: https://github.com/src-d/go-git/blob/eb243ba9a55ac029ab3f9b15157920c46e24078b/storage/filesystem/dotgit/dotgit.go#L268 Pushing another commit to the default branch on my repository opens the repository again, but looking at the commit history does produce a 500 error due to ``` ...uters/repo/commit.go:62:Commits() [E] CommitsByRange: packfile not found ``` For me this looks to be a bug in [go-git](https://github.com/src-d/go-git) not handling some case in a commit properly (as git itself does not report any errors)
Author
Owner

@smile34 commented on GitHub (Oct 4, 2019):

we have the same problem with one of our repositories - when clicking on the repository in the web interface we get error 500

Log entry:
.../xorm/session_get.go:99:nocacheGet() [I] [SQL] SELECT id, uid, repo_id FROM star WHERE uid=? AND repo_id=? LIMIT 1 []interface {}{1, 5}
...ules/context/repo.go:605:func1() [E] GetBranchCommit: packfile not found

using:
Gitea Version: 1.9.3 built with GNU Make 4.1, go1.12.9 : bindata, sqlite, sqlite_unlock_notify
Git Version: 2.16.2
Database: sqlite3
Operating System: Windows Server 2016 Datacenter

@smile34 commented on GitHub (Oct 4, 2019): we have the same problem with one of our repositories - when clicking on the repository in the web interface we get error 500 Log entry: .../xorm/session_get.go:99:nocacheGet() [I] [SQL] SELECT `id`, `uid`, `repo_id` FROM `star` WHERE `uid`=? AND `repo_id`=? LIMIT 1 []interface {}{1, 5} ...ules/context/repo.go:605:func1() [E] GetBranchCommit: packfile not found using: Gitea Version: 1.9.3 built with GNU Make 4.1, go1.12.9 : bindata, sqlite, sqlite_unlock_notify Git Version: 2.16.2 Database: sqlite3 Operating System: Windows Server 2016 Datacenter
Author
Owner

@lunny commented on GitHub (Oct 5, 2019):

@pampersrocker could you send an issue to https://github.com/src-d/go-git

@lunny commented on GitHub (Oct 5, 2019): @pampersrocker could you send an issue to https://github.com/src-d/go-git
Author
Owner

@pampersrocker commented on GitHub (Oct 6, 2019):

If you look at the issues in src-d/go-git ( src-d/go-git#1223 , src-d/go-git#1149 , src-d/go-git#1153 ) this is caused when a git gc run is not completed successfully and .tmp files reside in the .git/objects/packs directory.

A workaround for now is to manually run git gc in the affected repositories and let it complete. This fixed it on my end.
The actual fix for this issue seems to be already discussed in the mentioned src-d/go-git issues.

@pampersrocker commented on GitHub (Oct 6, 2019): If you look at the issues in [src-d/go-git](https://github.com/src-d/go-git) ( src-d/go-git#1223 , src-d/go-git#1149 , src-d/go-git#1153 ) this is caused when a `git gc` run is not completed successfully and `.tmp` files reside in the `.git/objects/packs` directory. A workaround for now is to manually run `git gc` in the affected repositories and let it complete. This fixed it on my end. The actual fix for this issue seems to be already discussed in the mentioned [src-d/go-git](https://github.com/src-d/go-git) issues.
Author
Owner

@smile34 commented on GitHub (Oct 7, 2019):

manually triggered garbage collection via gitea site administration page and the issue is fixed. Thank you!

@smile34 commented on GitHub (Oct 7, 2019): manually triggered garbage collection via gitea site administration page and the issue is fixed. Thank you!
Author
Owner

@robertschulze commented on GitHub (Oct 15, 2019):

Manually running git gc did the trick for me.
Thanks!

@robertschulze commented on GitHub (Oct 15, 2019): Manually running `git gc` did the trick for me. Thanks!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#4038