mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Ensure that sessions are passed into queries that could use the database to prevent deadlocks (#5718)
* Fixed deadlock in CreateComment * Fix possible deadlock in UpdateIssueDeadline from createDeadlineComment * Ensure that calls to IsTimeTracker enabled are called within session Signed-off-by: Andrew Thornton <art27@cantab.net> * Ensure that calls to reactionList are also called within session Signed-off-by: Andrew Thornton <art27@cantab.net> * Ensure all calls in NewPullRequest with the session are called within the session Signed-off-by: Andrew Thornton <art27@cantab.net> * Deal with potential deadlocks in repo Signed-off-by: Andrew Thornton <art27@cantab.net> * Ensure that isStaring is checked within our transaction Signed-off-by: Andrew Thornton <art27@cantab.net> * Fix mistake in isOrganizationMember Sorry.
This commit is contained in:
@@ -103,7 +103,11 @@ func (issue *Issue) loadRepo(e Engine) (err error) {
|
||||
|
||||
// IsTimetrackerEnabled returns true if the repo enables timetracking
|
||||
func (issue *Issue) IsTimetrackerEnabled() bool {
|
||||
if err := issue.loadRepo(x); err != nil {
|
||||
return issue.isTimetrackerEnabled(x)
|
||||
}
|
||||
|
||||
func (issue *Issue) isTimetrackerEnabled(e Engine) bool {
|
||||
if err := issue.loadRepo(e); err != nil {
|
||||
log.Error(4, fmt.Sprintf("loadRepo: %v", err))
|
||||
return false
|
||||
}
|
||||
@@ -196,7 +200,7 @@ func (issue *Issue) loadReactions(e Engine) (err error) {
|
||||
return err
|
||||
}
|
||||
// Load reaction user data
|
||||
if _, err := ReactionList(reactions).LoadUsers(); err != nil {
|
||||
if _, err := ReactionList(reactions).loadUsers(e); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -255,7 +259,7 @@ func (issue *Issue) loadAttributes(e Engine) (err error) {
|
||||
if err = issue.loadComments(e); err != nil {
|
||||
return err
|
||||
}
|
||||
if issue.IsTimetrackerEnabled() {
|
||||
if issue.isTimetrackerEnabled(e) {
|
||||
if err = issue.loadTotalTimes(e); err != nil {
|
||||
return err
|
||||
}
|
||||
|
Reference in New Issue
Block a user