diff --git a/pkg/db/db.go b/pkg/db/db.go index 1d8f331fa..13ee7e6ed 100644 --- a/pkg/db/db.go +++ b/pkg/db/db.go @@ -403,9 +403,13 @@ func WipeEverything() error { return nil } -// NewSession creates a new xorm session +// NewSession creates a new xorm session with an active transaction. +// The caller must call s.Commit() on success or s.Rollback() on error. +// s.Close() will auto-rollback any uncommitted transaction. func NewSession() *xorm.Session { - return x.NewSession() + s := x.NewSession() + _ = s.Begin() + return s } // Type returns the db type of the currently configured db