-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
Description
Description
In a Gitea instance with a large number of stale LFS objects, I'm experiencing a hang when running gitea doctor check --run gc-lfs The hang occurs when the command attempts to GC the first repo that has LFS files. The instance is running 1.24.6 on Ubuntu and is using the sqlite backend. The LFS files are stored in the local filesystem.
Gitea Version
1.25.4
Can you reproduce the bug on the Gitea demo site?
No
Log Gist
No response
Screenshots
No response
Git Version
No response
Operating System
No response
How are you running Gitea?
I spent a little bit time debugging and was able to reproduce this issue with a new instance of gitea using a single repo with a tiny number of LFS files. I used a local build of the v1.25.4 branch (on macOS), though I had to make a tiny change to the OlderThan value passed from garbageCollectLFSCheck in order to bypass the 1-week early out check.
From my investigation, the issue appears to be in IterateLFSMetaObjectsForRepo loop. When OrderByUpdated is true (the default) the loop will continue even when the query returns less batchSize but not zero. Presumably the issue is that the if opts.OrderByUpdated path is not including the check
sess.And("`lfs_meta_object`.id > ?", id)
so query returns the same results on every iteration. Ideally the loop should terminate if the returned beans are less than the batch size
I'm including a callstack in case it helps
git.IterateLFSMetaObjectsForRepo (/tmp/gitea-latest/models/git/lfs.go:377)
repository.GarbageCollectLFSMetaObjectsForRepo (/tmp/gitea-latest/services/repository/lfs.go:84)
repository.GarbageCollectLFSMetaObjects.func1 (/tmp/gitea-latest/services/repository/lfs.go:55)
git.IterateRepositoryIDsWithLFSMetaObjects (/tmp/gitea-latest/models/git/lfs.go:336)
repository.GarbageCollectLFSMetaObjects (/tmp/gitea-latest/services/repository/lfs.go:46)
doctor.garbageCollectLFSCheck (/tmp/gitea-latest/services/doctor/lfs.go:33)
doctor.RunChecks (/tmp/gitea-latest/services/doctor/doctor.go:109)
cmd.runDoctorCheck (/tmp/gitea-latest/cmd/doctor.go:214)
v3.(*Command).run (/go/pkg/mod/github.com/urfave/cli/v3@v3.4.1/command_run.go:344)
v3.(*Command).run (/go/pkg/mod/github.com/urfave/cli/v3@v3.4.1/command_run.go:278)
v3.(*Command).run (/go/pkg/mod/github.com/urfave/cli/v3@v3.4.1/command_run.go:278)
v3.(*Command).Run (/go/pkg/mod/github.com/urfave/cli/v3@v3.4.1/command_run.go:94)
cmd.RunMainApp (/tmp/gitea-latest/cmd/main.go:158)
main.main (/tmp/gitea-latest/main.go:46)
runtime.main (/opt/local/lib/go/src/runtime/proc.go:285)
runtime.goexit (/opt/local/lib/go/src/runtime/asm_arm64.s:1268)
Database
SQLite