[PR #4594] [MERGED] Fix bugs when too many IN variables #17428

Closed
opened 2025-11-02 13:20:09 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/go-gitea/gitea/pull/4594
Author: @lunny
Created: 8/2/2018
Status: Merged
Merged: 8/2/2018
Merged by: @lunny

Base: masterHead: lunny/fix_db_lock


📝 Commits (2)

  • 0f465a1 fix bugs when too many IN variables
  • 7b10846 Merge branch 'master' into lunny/fix_db_lock

📊 Changes

1 file changed (+194 additions, -95 deletions)

View changed files

📝 models/issue_list.go (+194 -95)

📄 Description

From gitea.log I found the error log.

2018/08/02 06:39:52 [...gitea/models/repo.go:2337 CheckRepoStats()] [E] Update repository count 'num_watches'[6452]: database table is locked: repository
2018/08/02 06:39:56 [...les/indexer/issue.go:67 InitIssueIndexer()] [E] InitIssueIndexer: populate index, LoadAttributes: too many SQL variables

From xorm.log I found the SQL.

SELECT * FROM `label` LEFT JOIN issue_label ON issue_label.label_id = label.id WHERE `issue_label`.`issue_id` IN (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?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,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?

Logs from demo site and the bug resulted the demo site restarted loop. This issue will occupy after you have many issues/users(maybe > 1000) so we haven't find it before. I think this PR will fix that problem and will recover the demo site.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/go-gitea/gitea/pull/4594 **Author:** [@lunny](https://github.com/lunny) **Created:** 8/2/2018 **Status:** ✅ Merged **Merged:** 8/2/2018 **Merged by:** [@lunny](https://github.com/lunny) **Base:** `master` ← **Head:** `lunny/fix_db_lock` --- ### 📝 Commits (2) - [`0f465a1`](https://github.com/go-gitea/gitea/commit/0f465a15bc80b46582b0b81f1f73427172950dc6) fix bugs when too many IN variables - [`7b10846`](https://github.com/go-gitea/gitea/commit/7b10846f148f21b41ee43c8b1cd341275d6c99c8) Merge branch 'master' into lunny/fix_db_lock ### 📊 Changes **1 file changed** (+194 additions, -95 deletions) <details> <summary>View changed files</summary> 📝 `models/issue_list.go` (+194 -95) </details> ### 📄 Description From gitea.log I found the error log. ``` 2018/08/02 06:39:52 [...gitea/models/repo.go:2337 CheckRepoStats()] [E] Update repository count 'num_watches'[6452]: database table is locked: repository 2018/08/02 06:39:56 [...les/indexer/issue.go:67 InitIssueIndexer()] [E] InitIssueIndexer: populate index, LoadAttributes: too many SQL variables ``` From xorm.log I found the SQL. ``` SELECT * FROM `label` LEFT JOIN issue_label ON issue_label.label_id = label.id WHERE `issue_label`.`issue_id` IN (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?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,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,? ``` Logs from demo site and the bug resulted the demo site restarted loop. This issue will occupy after you have many issues/users(maybe > 1000) so we haven't find it before. I think this PR will fix that problem and will recover the demo site. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2025-11-02 13:20:09 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#17428