Skip to content

Fix bug when do LFS GC#36500

Merged
lunny merged 16 commits intogo-gitea:mainfrom
lunny:lunny/fix_lfs_gc
Feb 12, 2026
Merged

Fix bug when do LFS GC#36500
lunny merged 16 commits intogo-gitea:mainfrom
lunny:lunny/fix_lfs_gc

Conversation

@lunny
Copy link
Copy Markdown
Member

@lunny lunny commented Jan 30, 2026

Fix #36448

Removed unnecessary parameters from the LFS GC process and switched to an ORDER BY id ASC strategy with a last-ID cursor to avoid missing or duplicating meta object IDs.

@lunny lunny added type/bug backport/v1.25 This PR should be backported to Gitea 1.25 labels Jan 30, 2026
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jan 30, 2026
@github-actions github-actions bot added the modifies/go Pull requests that update Go code label Jan 30, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes the LFS GC hang reported in #36448 by making LFS meta-object iteration stable and monotonic (ID-based cursor), preventing repeated batches when records are updated during iteration.

Changes:

  • Simplified IterateLFSMetaObjectsForRepoOptions by removing unused/unsafe iteration modes.
  • Reworked IterateLFSMetaObjectsForRepo to page via ORDER BY id ASC + id > lastID cursor (no offset paging).
  • Added regression tests covering GC autofix and iteration behavior when rows are updated mid-iteration.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
services/repository/lfs.go Stops passing the removed iteration parameters; relies on the new ID-cursor iteration behavior.
models/git/lfs.go Implements ID-based cursor pagination for LFSMetaObject iteration and removes the old ordering/offset options.
services/repository/lfs_test.go Adds a repo-scoped GC autofix test (and imports modules/test for mocking).
models/git/lfs_test.go Adds a regression test ensuring iteration doesn’t skip/hang when meta rows are updated during the loop.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Jan 31, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

lunny and others added 3 commits February 12, 2026 09:43
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Lunny Xiao <xiaolunwen@gmail.com>
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Feb 12, 2026
@lunny lunny merged commit d69b786 into go-gitea:main Feb 12, 2026
24 checks passed
@GiteaBot GiteaBot added this to the 1.26.0 milestone Feb 12, 2026
@lunny lunny deleted the lunny/fix_lfs_gc branch February 12, 2026 23:27
GiteaBot pushed a commit to GiteaBot/gitea that referenced this pull request Feb 13, 2026
Fix go-gitea#36448

Removed unnecessary parameters from the LFS GC process and switched to
an ORDER BY id ASC strategy with a last-ID cursor to avoid missing or
duplicating meta object IDs.

---------

Signed-off-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@GiteaBot GiteaBot added the backport/done All backports for this PR have been created label Feb 13, 2026
silverwind pushed a commit that referenced this pull request Feb 13, 2026
Backport #36500 by @lunny

Fix #36448

Removed unnecessary parameters from the LFS GC process and switched to
an ORDER BY id ASC strategy with a last-ID cursor to avoid missing or
duplicating meta object IDs.

Signed-off-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
silverwind added a commit to silverwind/gitea that referenced this pull request Feb 14, 2026
* origin/main: (2555 commits)
  automate updating nix flakes (go-gitea#35641)
  Update AGENTS.md instructions (go-gitea#36627)
  use user id in noreply emails (go-gitea#36550)
  feat(db): Improve BuildCaseInsensitiveLike with lowercase (go-gitea#36598)
  [skip ci] Updated translations via Crowdin
  BUG: Fix workflow run jobs API returning null steps (go-gitea#36603)
  Refactor highlight and diff (go-gitea#36599)
  Fix bug when do LFS GC (go-gitea#36500)
  feature to be able to filter project boards by milestones (go-gitea#36321)
  Update emoji data for Unicode 16 (go-gitea#36596)
  Adapt monaco error matching pattern to recent webpack config change (go-gitea#36533)
  Fix a bug user could change another user's primary email (go-gitea#36586)
  fix(repo-editor): disable Monaco `editContext` to avoid bugs with lost focus (go-gitea#36585)
  Fine tune diff highlighting (go-gitea#36592)
  Add code editor setting dropdowns (go-gitea#36534)
  Update to go 1.26.0 and golangci-lint 2.9.0 (go-gitea#36588)
  Improve diff highlighting (go-gitea#36583)
  Fix markup code block layout (go-gitea#36578)
  Remove striped tables in UI (go-gitea#36509)
  Fix vertical alignment of `.commit-sign-badge` children (go-gitea#36570)
  ...

# Conflicts:
#	custom/conf/app.example.ini
#	docs/content/administration/config-cheat-sheet.en-us.md
#	docs/content/administration/config-cheat-sheet.zh-cn.md
#	modules/setting/security.go
#	routers/common/errpage.go
#	services/context/api.go
#	services/context/context.go
Sirherobrine23 pushed a commit to Sirherobrine23/gitea that referenced this pull request Mar 4, 2026
Fix go-gitea#36448

Removed unnecessary parameters from the LFS GC process and switched to
an ORDER BY id ASC strategy with a last-ID cursor to avoid missing or
duplicating meta object IDs.

---------

Signed-off-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/done All backports for this PR have been created backport/v1.25 This PR should be backported to Gitea 1.25 lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/go Pull requests that update Go code type/bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hang when running the gc-lfs doctor

6 participants