Skip to content

fix(lfs): ensure lock listing paginates with a total order - #38850

Open
viralpraxis wants to merge 1 commit into
go-gitea:mainfrom
viralpraxis:fix-lfs-lock-pagination-total-order
Open

fix(lfs): ensure lock listing paginates with a total order#38850
viralpraxis wants to merge 1 commit into
go-gitea:mainfrom
viralpraxis:fix-lfs-lock-pagination-total-order

Conversation

@viralpraxis

@viralpraxis viralpraxis commented Aug 9, 2026

Copy link
Copy Markdown

GetLFSLockByRepoID applies LIMIT/OFFSET to a query with no ORDER BY. The order of such a query is unspecified (according to the SQL standard), so the resulting queryset might be inconsistent.

These locks AFAIK are never updated, so in practice the order is insertion-based, but that's not guaranteed.

Found by the pg_disorder PostgreSQL extension

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Aug 9, 2026
`GetLFSLockByRepoID` applies `LIMIT`/`OFFSET` to a query with no `ORDER BY`.
The order of such a query is unspecified (according to the SQL standard),
so two page requests may see different orders and the pages stop tiling:
one lock is returned twice while another is never returned at all.

These locks are never updated, so in practice the order is insertion-based,
but that's not guaranteed.

Found by the `pg_disorder` PostgreSQL extension:
https://github.com/viralpraxis/pg_disorder

Assisted-by: Claude Code:claude-opus-5
@viralpraxis
viralpraxis force-pushed the fix-lfs-lock-pagination-total-order branch from a803cb0 to 8cc3010 Compare August 12, 2026 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. topic/lfs type/bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants