Skip to content

Fix repo API listing stability #12057

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 2, 2020

Conversation

cboylan
Copy link
Contributor

@cboylan cboylan commented Jun 25, 2020

This addresses #12056

Repo listings are paginated in the API now. Unfortunately, they are
ORDER BY updated_unix which only has second resolution. This means that
if you do a listing when multiple projects were created at the same time
you can unstable ordering. If that unstable ordering happens at a page
boundary you may fail to get a complete repo listing.

To make things worse sorting by updated_unix means that we may never get
a complete listing because udpated_unix can change independent of our
API calls.

Fix this by making the API repo listing order by id instead.

@cboylan
Copy link
Contributor Author

cboylan commented Jun 25, 2020

As noted in the Issue I'm not sure this is a complete fix as other API pagination methods may have similar problems. I'm also in the process of getting this tested properly locally, but I wanted to get this up so that others could offer suggestions or additional fixes if necessary.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jun 25, 2020
@cboylan
Copy link
Contributor Author

cboylan commented Jun 25, 2020

I'm doing more testing locally and I'm not sure this fixes the issue for us yet. In any case it should serve as a starting point for figuring it out.

@lafriks lafriks added this to the 1.13.0 milestone Jun 25, 2020
@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 Jun 27, 2020
@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 Jun 28, 2020
Repo listings are paginated in the API now. Unfortunately, they are
ORDER BY updated_unix which only has second resolution. This means that
if you do a listing when multiple projects were created at the same time
you can unstable ordering. If that unstable ordering happens at a page
boundary you may fail to get a complete repo listing.

To make things worse sorting by updated_unix means that we may never get
a complete listing because udpated_unix can change independent of our
API calls.

Fix this by making the API repo listing order by id instead.
@cboylan cboylan force-pushed the fix-repo-list-stability branch from 57bbb30 to a67f21c Compare June 28, 2020 15:51
@cboylan
Copy link
Contributor Author

cboylan commented Jun 28, 2020

New version does and ascending not descending sort. I realized that if a new repo is added during a listing we'll get that inserted at the front not the end using descending. If we use ascending it will be added at the end and a user paging through the list will see the new repo. In the end both should work, but ascending is a bit more friendly I think.

@zeripath
Copy link
Contributor

zeripath commented Jul 2, 2020

make lg-tm work

@zeripath zeripath merged commit 7e401fb into go-gitea:master Jul 2, 2020
ydelafollye pushed a commit to ydelafollye/gitea that referenced this pull request Jul 31, 2020
Repo listings are paginated in the API now. Unfortunately, they are
ORDER BY updated_unix which only has second resolution. This means that
if you do a listing when multiple projects were created at the same time
you can unstable ordering. If that unstable ordering happens at a page
boundary you may fail to get a complete repo listing.

To make things worse sorting by updated_unix means that we may never get
a complete listing because udpated_unix can change independent of our
API calls.

Fix this by making the API repo listing order by id instead.
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants