mirror of https://github.com/go-gitea/gitea.git
Fix sqlite deadlock when assigning to a PR (#5640)
* Fix sqlite deadlock when assigning to a PR Fix 5639 Signed-off-by: Andrew Thornton <art27@cantab.net> * More possible deadlocks found and fixed Signed-off-by: Andrew Thornton <art27@cantab.net>
This commit is contained in:
parent
9e901039e7
commit
6311e4ce6a
|
@ -1402,7 +1402,7 @@ func UpdateIssueMentions(e Engine, issueID int64, mentions []string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
memberIDs := make([]int64, 0, user.NumMembers)
|
memberIDs := make([]int64, 0, user.NumMembers)
|
||||||
orgUsers, err := GetOrgUsersByOrgID(user.ID)
|
orgUsers, err := getOrgUsersByOrgID(e, user.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("GetOrgUsersByOrgID [%d]: %v", user.ID, err)
|
return fmt.Errorf("GetOrgUsersByOrgID [%d]: %v", user.ID, err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,11 @@ func (issue *Issue) loadAssignees(e Engine) (err error) {
|
||||||
|
|
||||||
// GetAssigneesByIssue returns everyone assigned to that issue
|
// GetAssigneesByIssue returns everyone assigned to that issue
|
||||||
func GetAssigneesByIssue(issue *Issue) (assignees []*User, err error) {
|
func GetAssigneesByIssue(issue *Issue) (assignees []*User, err error) {
|
||||||
err = issue.loadAssignees(x)
|
return getAssigneesByIssue(x, issue)
|
||||||
|
}
|
||||||
|
|
||||||
|
func getAssigneesByIssue(e Engine, issue *Issue) (assignees []*User, err error) {
|
||||||
|
err = issue.loadAssignees(e)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return assignees, err
|
return assignees, err
|
||||||
}
|
}
|
||||||
|
@ -173,7 +177,7 @@ func (issue *Issue) changeAssignee(sess *xorm.Session, doer *User, assigneeID in
|
||||||
issue.PullRequest.Issue = issue
|
issue.PullRequest.Issue = issue
|
||||||
apiPullRequest := &api.PullRequestPayload{
|
apiPullRequest := &api.PullRequestPayload{
|
||||||
Index: issue.Index,
|
Index: issue.Index,
|
||||||
PullRequest: issue.PullRequest.APIFormat(),
|
PullRequest: issue.PullRequest.apiFormat(sess),
|
||||||
Repository: issue.Repo.innerAPIFormat(sess, mode, false),
|
Repository: issue.Repo.innerAPIFormat(sess, mode, false),
|
||||||
Sender: doer.APIFormat(),
|
Sender: doer.APIFormat(),
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ func mailIssueCommentToParticipants(e Engine, issue *Issue, doer *User, content
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assignees must receive any communications
|
// Assignees must receive any communications
|
||||||
assignees, err := GetAssigneesByIssue(issue)
|
assignees, err := getAssigneesByIssue(e, issue)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ func newIssueUsers(e Engine, repo *Repository, issue *Issue) error {
|
||||||
func updateIssueAssignee(e *xorm.Session, issue *Issue, assigneeID int64) (removed bool, err error) {
|
func updateIssueAssignee(e *xorm.Session, issue *Issue, assigneeID int64) (removed bool, err error) {
|
||||||
|
|
||||||
// Check if the user exists
|
// Check if the user exists
|
||||||
assignee, err := GetUserByID(assigneeID)
|
assignee, err := getUserByID(e, assigneeID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -393,8 +393,12 @@ func GetOrgUsersByUserID(uid int64, all bool) ([]*OrgUser, error) {
|
||||||
|
|
||||||
// GetOrgUsersByOrgID returns all organization-user relations by organization ID.
|
// GetOrgUsersByOrgID returns all organization-user relations by organization ID.
|
||||||
func GetOrgUsersByOrgID(orgID int64) ([]*OrgUser, error) {
|
func GetOrgUsersByOrgID(orgID int64) ([]*OrgUser, error) {
|
||||||
|
return getOrgUsersByOrgID(x, orgID)
|
||||||
|
}
|
||||||
|
|
||||||
|
func getOrgUsersByOrgID(e Engine, orgID int64) ([]*OrgUser, error) {
|
||||||
ous := make([]*OrgUser, 0, 10)
|
ous := make([]*OrgUser, 0, 10)
|
||||||
err := x.
|
err := e.
|
||||||
Where("org_id=?", orgID).
|
Where("org_id=?", orgID).
|
||||||
Find(&ous)
|
Find(&ous)
|
||||||
return ous, err
|
return ous, err
|
||||||
|
|
|
@ -113,15 +113,15 @@ func notifyWatchers(e Engine, act *Action) error {
|
||||||
|
|
||||||
switch act.OpType {
|
switch act.OpType {
|
||||||
case ActionCommitRepo, ActionPushTag, ActionDeleteTag, ActionDeleteBranch:
|
case ActionCommitRepo, ActionPushTag, ActionDeleteTag, ActionDeleteBranch:
|
||||||
if !act.Repo.CheckUnitUser(act.UserID, false, UnitTypeCode) {
|
if !act.Repo.checkUnitUser(e, act.UserID, false, UnitTypeCode) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
case ActionCreateIssue, ActionCommentIssue, ActionCloseIssue, ActionReopenIssue:
|
case ActionCreateIssue, ActionCommentIssue, ActionCloseIssue, ActionReopenIssue:
|
||||||
if !act.Repo.CheckUnitUser(act.UserID, false, UnitTypeIssues) {
|
if !act.Repo.checkUnitUser(e, act.UserID, false, UnitTypeIssues) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
case ActionCreatePullRequest, ActionMergePullRequest, ActionClosePullRequest, ActionReopenPullRequest:
|
case ActionCreatePullRequest, ActionMergePullRequest, ActionClosePullRequest, ActionReopenPullRequest:
|
||||||
if !act.Repo.CheckUnitUser(act.UserID, false, UnitTypePullRequests) {
|
if !act.Repo.checkUnitUser(e, act.UserID, false, UnitTypePullRequests) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue