This repository was archived by the owner on Sep 7, 2021. It is now read-only.
This repository is currently being migrated. It's locked while the migration is in progress.
This repository was archived by the owner on Sep 7, 2021. It is now read-only.
Session not completely cleaned #1185
Open
Description
Hi!
In Gitea at https://github.com/go-gitea/gitea/blob/master/models/issue.go#L1349
func Issues(opts *IssuesOptions) ([]*Issue, error) {
sess := x.NewSession()
defer sess.Close()
if err := opts.setupSession(sess); err != nil {
return nil, err
}
sortIssuesSession(sess, opts.SortType)
issues := make([]*Issue, 0, setting.UI.IssuePagingNum)
if err := sess.Find(&issues); err != nil {
return nil, fmt.Errorf("Find: %v", err)
}
if err := IssueList(issues).LoadAttributes(); err != nil {
return nil, fmt.Errorf("LoadAttributes: %v", err)
}
return issues, nil
}
If we change the LoadAttributes
function to perform its lookups within the same session the results are not the same as those without it, because it appears that at least some of the setup performed in opts.setupSession
is not reset following the Find
above.
Although this doesn't present a problem at the moment because there is no transaction created and no changes are made to the database, the lack of a complete reset could cause unpredictable heisenbugs elsewhere.