mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-21 08:43:08 +00:00
fix potential lock when sqlite (#1647)
This commit is contained in:
parent
b6206e4788
commit
0f3923c4d7
1 changed files with 26 additions and 20 deletions
|
@ -1058,29 +1058,30 @@ func (pr *PullRequest) checkAndUpdateStatus() {
|
||||||
// TODO: test more pull requests at same time.
|
// TODO: test more pull requests at same time.
|
||||||
func TestPullRequests() {
|
func TestPullRequests() {
|
||||||
prs := make([]*PullRequest, 0, 10)
|
prs := make([]*PullRequest, 0, 10)
|
||||||
x.Iterate(PullRequest{
|
|
||||||
Status: PullRequestStatusChecking,
|
|
||||||
},
|
|
||||||
func(idx int, bean interface{}) error {
|
|
||||||
pr := bean.(*PullRequest)
|
|
||||||
|
|
||||||
if err := pr.GetBaseRepo(); err != nil {
|
err := x.Where("status = ?", PullRequestStatusChecking).Find(&prs)
|
||||||
log.Error(3, "GetBaseRepo: %v", err)
|
if err != nil {
|
||||||
return nil
|
log.Error(3, "Find Checking PRs", err)
|
||||||
}
|
return
|
||||||
if pr.manuallyMerged() {
|
}
|
||||||
return nil
|
|
||||||
}
|
var checkedPRs = make(map[int64]struct{})
|
||||||
if err := pr.testPatch(); err != nil {
|
|
||||||
log.Error(3, "testPatch: %v", err)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
prs = append(prs, pr)
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
|
|
||||||
// Update pull request status.
|
// Update pull request status.
|
||||||
for _, pr := range prs {
|
for _, pr := range prs {
|
||||||
|
checkedPRs[pr.ID] = struct{}{}
|
||||||
|
if err := pr.GetBaseRepo(); err != nil {
|
||||||
|
log.Error(3, "GetBaseRepo: %v", err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if pr.manuallyMerged() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if err := pr.testPatch(); err != nil {
|
||||||
|
log.Error(3, "testPatch: %v", err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
pr.checkAndUpdateStatus()
|
pr.checkAndUpdateStatus()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1089,7 +1090,12 @@ func TestPullRequests() {
|
||||||
log.Trace("TestPullRequests[%v]: processing test task", prID)
|
log.Trace("TestPullRequests[%v]: processing test task", prID)
|
||||||
pullRequestQueue.Remove(prID)
|
pullRequestQueue.Remove(prID)
|
||||||
|
|
||||||
pr, err := GetPullRequestByID(com.StrTo(prID).MustInt64())
|
id := com.StrTo(prID).MustInt64()
|
||||||
|
if _, ok := checkedPRs[id]; ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
pr, err := GetPullRequestByID(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(4, "GetPullRequestByID[%s]: %v", prID, err)
|
log.Error(4, "GetPullRequestByID[%s]: %v", prID, err)
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Reference in a new issue