-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Closed
Description
Gitea Version
1.16.4
Git Version
2.25.1
Operating System
Linux
How are you running Gitea?
Nothing fancy
curl -L "https://github.com/go-gitea/gitea/releases/download/v1.16.4/gitea-1.16.4-linux-amd64" --output /tmp/gitea
/tmp/gitea
Database
PostgreSQL
Can you reproduce the bug on the Gitea demo site?
No
Log Gist
Mar 18 21:54:55 linux- gitea[584975]: 2022/03/18 21:54:55 ...pi/v1/admin/adopt.go:51:ListUnadoptedRepositories() [E] InternalServerError: Count: pq: got 236972 parameters but PostgreSQL only supports 65535 parameters
Mar 18 21:54:55 linux gitea[584975]: 2022/03/18 21:54:55 router: completed GET /api/v1/admin/unadopted?page=1&limit=1000&pattern=&access_token=7feec787664a21a74aec942a71343b46d2d52360&sudo=&token= for 129.6.76.113:0, 500 Internal Server Error in 3618.9ms @ admin/adopt.go:20(admin.ListUnadoptedRepositories)
Description
The bug
I have more than 65535 unadopted repositories in gitea-repositories
.
When I want to list them, I have a 500 HTTP status:
curl -X 'GET' 'http://localhost:3000/api/v1/admin/unadopted?page=1&limit=1000' -H 'authorization: Basic XXXXX'`
The Cause
After some voodoo debugging, I figured out the error happens in /services/repository/adopt.go:249, after the function call at services/repository/adopt.go:347
// Caller is services/repository/adopt.go:L347
// services/repository/adopt.go:249
repos, _, err := models.GetUserRepositories(&models.SearchRepoOptions{
Actor: ctxUser,
Private: true,
ListOptions: db.ListOptions{
Page: 1,
PageSize: len(repoNamesToCheck), // len(repoNamesToCheck) is greater than 65535
}, LowerNames: repoNamesToCheck, // 💀 the array contains more than 65535 items
})
if err != nil {
return err // 🔥 Count: pq: got 236972 parameters but PostgreSQL only supports 65535 parameters"
}
```
Metadata
Metadata
Assignees
Labels
Type
Projects
Relationships
Development
Select code repository
Activity
Use IterateBufferSize whilst querying repositories during adoption check
Use IterateBufferSize whilst querying repositories during adoption ch…
Use IterateBufferSize whilst querying repositories during adoption ch…
Use IterateBufferSize whilst querying repositories during adoption ch…
Use IterateBufferSize whilst querying repositories during adoption ch…