Browse Source

Refactor session close as xorm already does everything needed internally (#2020)

Lauris BH 2 years ago
parent
commit
6db387a21e

+ 1 - 1
models/attachment.go

@@ -48,7 +48,7 @@ func (a *Attachment) AfterSet(colName string, _ xorm.Cell) {
48 48
 // IncreaseDownloadCount is update download count + 1
49 49
 func (a *Attachment) IncreaseDownloadCount() error {
50 50
 	sess := x.NewSession()
51
-	defer sessionRelease(sess)
51
+	defer sess.Close()
52 52
 
53 53
 	// Update download count.
54 54
 	if _, err := sess.Exec("UPDATE `attachment` SET download_count=download_count+1 WHERE id=?", a.ID); err != nil {

+ 3 - 3
models/branches.go

@@ -95,7 +95,7 @@ func (repo *Repository) AddProtectedBranch(branchName string, canPush bool) erro
95 95
 	}
96 96
 
97 97
 	sess := x.NewSession()
98
-	defer sessionRelease(sess)
98
+	defer sess.Close()
99 99
 	if err = sess.Begin(); err != nil {
100 100
 		return err
101 101
 	}
@@ -126,7 +126,7 @@ func (repo *Repository) ChangeProtectedBranch(id int64, canPush bool) error {
126 126
 	ProtectedBranch.CanPush = canPush
127 127
 
128 128
 	sess := x.NewSession()
129
-	defer sessionRelease(sess)
129
+	defer sess.Close()
130 130
 	if err = sess.Begin(); err != nil {
131 131
 		return err
132 132
 	}
@@ -146,7 +146,7 @@ func (repo *Repository) DeleteProtectedBranch(id int64) (err error) {
146 146
 	}
147 147
 
148 148
 	sess := x.NewSession()
149
-	defer sessionRelease(sess)
149
+	defer sess.Close()
150 150
 	if err = sess.Begin(); err != nil {
151 151
 		return err
152 152
 	}

+ 2 - 2
models/gpg_key.go

@@ -127,7 +127,7 @@ func AddGPGKey(ownerID int64, content string) (*GPGKey, error) {
127 127
 
128 128
 	//Get DB session
129 129
 	sess := x.NewSession()
130
-	defer sessionRelease(sess)
130
+	defer sess.Close()
131 131
 	if err = sess.Begin(); err != nil {
132 132
 		return nil, err
133 133
 	}
@@ -267,7 +267,7 @@ func DeleteGPGKey(doer *User, id int64) (err error) {
267 267
 	}
268 268
 
269 269
 	sess := x.NewSession()
270
-	defer sessionRelease(sess)
270
+	defer sess.Close()
271 271
 	if err = sess.Begin(); err != nil {
272 272
 		return err
273 273
 	}

+ 4 - 4
models/issue.go

@@ -406,7 +406,7 @@ func (issue *Issue) clearLabels(e *xorm.Session, doer *User) (err error) {
406 406
 // Triggers appropriate WebHooks, if any.
407 407
 func (issue *Issue) ClearLabels(doer *User) (err error) {
408 408
 	sess := x.NewSession()
409
-	defer sessionRelease(sess)
409
+	defer sess.Close()
410 410
 	if err = sess.Begin(); err != nil {
411 411
 		return err
412 412
 	}
@@ -470,7 +470,7 @@ func (ts labelSorter) Swap(i, j int) {
470 470
 // Triggers appropriate WebHooks, if any.
471 471
 func (issue *Issue) ReplaceLabels(labels []*Label, doer *User) (err error) {
472 472
 	sess := x.NewSession()
473
-	defer sessionRelease(sess)
473
+	defer sess.Close()
474 474
 	if err = sess.Begin(); err != nil {
475 475
 		return err
476 476
 	}
@@ -598,7 +598,7 @@ func (issue *Issue) changeStatus(e *xorm.Session, doer *User, repo *Repository,
598 598
 // ChangeStatus changes issue status to open or closed.
599 599
 func (issue *Issue) ChangeStatus(doer *User, repo *Repository, isClosed bool) (err error) {
600 600
 	sess := x.NewSession()
601
-	defer sessionRelease(sess)
601
+	defer sess.Close()
602 602
 	if err = sess.Begin(); err != nil {
603 603
 		return err
604 604
 	}
@@ -899,7 +899,7 @@ func newIssue(e *xorm.Session, doer *User, opts NewIssueOptions) (err error) {
899 899
 // NewIssue creates new issue with labels for repository.
900 900
 func NewIssue(repo *Repository, issue *Issue, labelIDs []int64, uuids []string) (err error) {
901 901
 	sess := x.NewSession()
902
-	defer sessionRelease(sess)
902
+	defer sess.Close()
903 903
 	if err = sess.Begin(); err != nil {
904 904
 		return err
905 905
 	}

+ 2 - 2
models/issue_comment.go

@@ -502,7 +502,7 @@ type CreateCommentOptions struct {
502 502
 // CreateComment creates comment of issue or commit.
503 503
 func CreateComment(opts *CreateCommentOptions) (comment *Comment, err error) {
504 504
 	sess := x.NewSession()
505
-	defer sessionRelease(sess)
505
+	defer sess.Close()
506 506
 	if err = sess.Begin(); err != nil {
507 507
 		return nil, err
508 508
 	}
@@ -620,7 +620,7 @@ func UpdateComment(c *Comment) error {
620 620
 // DeleteComment deletes the comment
621 621
 func DeleteComment(comment *Comment) error {
622 622
 	sess := x.NewSession()
623
-	defer sessionRelease(sess)
623
+	defer sess.Close()
624 624
 	if err := sess.Begin(); err != nil {
625 625
 		return err
626 626
 	}

+ 4 - 4
models/issue_label.go

@@ -223,7 +223,7 @@ func DeleteLabel(repoID, labelID int64) error {
223 223
 	}
224 224
 
225 225
 	sess := x.NewSession()
226
-	defer sessionRelease(sess)
226
+	defer sess.Close()
227 227
 	if err = sess.Begin(); err != nil {
228 228
 		return err
229 229
 	}
@@ -298,7 +298,7 @@ func NewIssueLabel(issue *Issue, label *Label, doer *User) (err error) {
298 298
 	}
299 299
 
300 300
 	sess := x.NewSession()
301
-	defer sessionRelease(sess)
301
+	defer sess.Close()
302 302
 	if err = sess.Begin(); err != nil {
303 303
 		return err
304 304
 	}
@@ -327,7 +327,7 @@ func newIssueLabels(e *xorm.Session, issue *Issue, labels []*Label, doer *User)
327 327
 // NewIssueLabels creates a list of issue-label relations.
328 328
 func NewIssueLabels(issue *Issue, labels []*Label, doer *User) (err error) {
329 329
 	sess := x.NewSession()
330
-	defer sessionRelease(sess)
330
+	defer sess.Close()
331 331
 	if err = sess.Begin(); err != nil {
332 332
 		return err
333 333
 	}
@@ -375,7 +375,7 @@ func deleteIssueLabel(e *xorm.Session, issue *Issue, label *Label, doer *User) (
375 375
 // DeleteIssueLabel deletes issue-label relation.
376 376
 func DeleteIssueLabel(issue *Issue, label *Label, doer *User) (err error) {
377 377
 	sess := x.NewSession()
378
-	defer sessionRelease(sess)
378
+	defer sess.Close()
379 379
 	if err = sess.Begin(); err != nil {
380 380
 		return err
381 381
 	}

+ 3 - 3
models/issue_milestone.go

@@ -104,7 +104,7 @@ func (m *Milestone) APIFormat() *api.Milestone {
104 104
 // NewMilestone creates new milestone of repository.
105 105
 func NewMilestone(m *Milestone) (err error) {
106 106
 	sess := x.NewSession()
107
-	defer sessionRelease(sess)
107
+	defer sess.Close()
108 108
 	if err = sess.Begin(); err != nil {
109 109
 		return err
110 110
 	}
@@ -215,7 +215,7 @@ func ChangeMilestoneStatus(m *Milestone, isClosed bool) (err error) {
215 215
 	}
216 216
 
217 217
 	sess := x.NewSession()
218
-	defer sessionRelease(sess)
218
+	defer sess.Close()
219 219
 	if err = sess.Begin(); err != nil {
220 220
 		return err
221 221
 	}
@@ -330,7 +330,7 @@ func DeleteMilestoneByRepoID(repoID, id int64) error {
330 330
 	}
331 331
 
332 332
 	sess := x.NewSession()
333
-	defer sessionRelease(sess)
333
+	defer sess.Close()
334 334
 	if err = sess.Begin(); err != nil {
335 335
 		return err
336 336
 	}

+ 1 - 1
models/issue_user.go

@@ -69,7 +69,7 @@ func updateIssueUserByAssignee(e Engine, issue *Issue) (err error) {
69 69
 // UpdateIssueUserByAssignee updates issue-user relation for assignee.
70 70
 func UpdateIssueUserByAssignee(issue *Issue) (err error) {
71 71
 	sess := x.NewSession()
72
-	defer sessionRelease(sess)
72
+	defer sess.Close()
73 73
 	if err = sess.Begin(); err != nil {
74 74
 		return err
75 75
 	}

+ 2 - 2
models/lfs.go

@@ -56,7 +56,7 @@ func NewLFSMetaObject(m *LFSMetaObject) (*LFSMetaObject, error) {
56 56
 	}
57 57
 
58 58
 	sess := x.NewSession()
59
-	defer sessionRelease(sess)
59
+	defer sess.Close()
60 60
 	if err = sess.Begin(); err != nil {
61 61
 		return nil, err
62 62
 	}
@@ -94,7 +94,7 @@ func RemoveLFSMetaObjectByOid(oid string) error {
94 94
 	}
95 95
 
96 96
 	sess := x.NewSession()
97
-	defer sessionRelease(sess)
97
+	defer sess.Close()
98 98
 	if err := sess.Begin(); err != nil {
99 99
 		return err
100 100
 	}

+ 5 - 12
models/migrations/migrations.go

@@ -167,13 +167,6 @@ Please try to upgrade to a lower version (>= v0.6.0) first, then upgrade to curr
167 167
 	return nil
168 168
 }
169 169
 
170
-func sessionRelease(sess *xorm.Session) {
171
-	if !sess.IsCommitedOrRollbacked {
172
-		sess.Rollback()
173
-	}
174
-	sess.Close()
175
-}
176
-
177 170
 func fixLocaleFileLoadPanic(_ *xorm.Engine) error {
178 171
 	cfg, err := ini.Load(setting.CustomConf)
179 172
 	if err != nil {
@@ -214,7 +207,7 @@ func trimCommitActionAppURLPrefix(x *xorm.Engine) error {
214 207
 	}
215 208
 
216 209
 	sess := x.NewSession()
217
-	defer sessionRelease(sess)
210
+	defer sess.Close()
218 211
 	if err = sess.Begin(); err != nil {
219 212
 		return err
220 213
 	}
@@ -287,7 +280,7 @@ func issueToIssueLabel(x *xorm.Engine) error {
287 280
 	}
288 281
 
289 282
 	sess := x.NewSession()
290
-	defer sessionRelease(sess)
283
+	defer sess.Close()
291 284
 	if err = sess.Begin(); err != nil {
292 285
 		return err
293 286
 	}
@@ -330,7 +323,7 @@ func attachmentRefactor(x *xorm.Engine) error {
330 323
 	}
331 324
 
332 325
 	sess := x.NewSession()
333
-	defer sessionRelease(sess)
326
+	defer sess.Close()
334 327
 	if err = sess.Begin(); err != nil {
335 328
 		return err
336 329
 	}
@@ -408,7 +401,7 @@ func renamePullRequestFields(x *xorm.Engine) (err error) {
408 401
 	}
409 402
 
410 403
 	sess := x.NewSession()
411
-	defer sessionRelease(sess)
404
+	defer sess.Close()
412 405
 	if err = sess.Begin(); err != nil {
413 406
 		return err
414 407
 	}
@@ -492,7 +485,7 @@ func generateOrgRandsAndSalt(x *xorm.Engine) (err error) {
492 485
 	}
493 486
 
494 487
 	sess := x.NewSession()
495
-	defer sessionRelease(sess)
488
+	defer sess.Close()
496 489
 	if err = sess.Begin(); err != nil {
497 490
 		return err
498 491
 	}

+ 1 - 1
models/migrations/v13.go

@@ -23,7 +23,7 @@ func ldapUseSSLToSecurityProtocol(x *xorm.Engine) error {
23 23
 	}
24 24
 
25 25
 	sess := x.NewSession()
26
-	defer sessionRelease(sess)
26
+	defer sess.Close()
27 27
 	if err = sess.Begin(); err != nil {
28 28
 		return err
29 29
 	}

+ 0 - 7
models/models.go

@@ -49,13 +49,6 @@ type Engine interface {
49 49
 	Where(interface{}, ...interface{}) *xorm.Session
50 50
 }
51 51
 
52
-func sessionRelease(sess *xorm.Session) {
53
-	if !sess.IsCommitedOrRollbacked {
54
-		sess.Rollback()
55
-	}
56
-	sess.Close()
57
-}
58
-
59 52
 var (
60 53
 	x      *xorm.Engine
61 54
 	tables []interface{}

+ 2 - 2
models/org.go

@@ -127,7 +127,7 @@ func CreateOrganization(org, owner *User) (err error) {
127 127
 	org.Type = UserTypeOrganization
128 128
 
129 129
 	sess := x.NewSession()
130
-	defer sessionRelease(sess)
130
+	defer sess.Close()
131 131
 	if err = sess.Begin(); err != nil {
132 132
 		return err
133 133
 	}
@@ -481,7 +481,7 @@ func RemoveOrgUser(orgID, userID int64) error {
481 481
 	}
482 482
 
483 483
 	sess := x.NewSession()
484
-	defer sessionRelease(sess)
484
+	defer sess.Close()
485 485
 	if err := sess.Begin(); err != nil {
486 486
 		return err
487 487
 	}

+ 6 - 6
models/org_team.go

@@ -119,7 +119,7 @@ func (t *Team) AddRepository(repo *Repository) (err error) {
119 119
 	}
120 120
 
121 121
 	sess := x.NewSession()
122
-	defer sessionRelease(sess)
122
+	defer sess.Close()
123 123
 	if err = sess.Begin(); err != nil {
124 124
 		return err
125 125
 	}
@@ -180,7 +180,7 @@ func (t *Team) RemoveRepository(repoID int64) error {
180 180
 	}
181 181
 
182 182
 	sess := x.NewSession()
183
-	defer sessionRelease(sess)
183
+	defer sess.Close()
184 184
 	if err = sess.Begin(); err != nil {
185 185
 		return err
186 186
 	}
@@ -309,7 +309,7 @@ func UpdateTeam(t *Team, authChanged bool) (err error) {
309 309
 	}
310 310
 
311 311
 	sess := x.NewSession()
312
-	defer sessionRelease(sess)
312
+	defer sess.Close()
313 313
 	if err = sess.Begin(); err != nil {
314 314
 		return err
315 315
 	}
@@ -354,7 +354,7 @@ func DeleteTeam(t *Team) error {
354 354
 	}
355 355
 
356 356
 	sess := x.NewSession()
357
-	defer sessionRelease(sess)
357
+	defer sess.Close()
358 358
 	if err := sess.Begin(); err != nil {
359 359
 		return err
360 360
 	}
@@ -482,7 +482,7 @@ func AddTeamMember(team *Team, userID int64) error {
482 482
 	}
483 483
 
484 484
 	sess := x.NewSession()
485
-	defer sessionRelease(sess)
485
+	defer sess.Close()
486 486
 	if err := sess.Begin(); err != nil {
487 487
 		return err
488 488
 	}
@@ -584,7 +584,7 @@ func removeTeamMember(e Engine, team *Team, userID int64) error {
584 584
 // RemoveTeamMember removes member from given team of given organization.
585 585
 func RemoveTeamMember(team *Team, userID int64) error {
586 586
 	sess := x.NewSession()
587
-	defer sessionRelease(sess)
587
+	defer sess.Close()
588 588
 	if err := sess.Begin(); err != nil {
589 589
 		return err
590 590
 	}

+ 2 - 2
models/pull.go

@@ -406,7 +406,7 @@ func (pr *PullRequest) setMerged() (err error) {
406 406
 	pr.HasMerged = true
407 407
 
408 408
 	sess := x.NewSession()
409
-	defer sessionRelease(sess)
409
+	defer sess.Close()
410 410
 	if err = sess.Begin(); err != nil {
411 411
 		return err
412 412
 	}
@@ -602,7 +602,7 @@ func (pr *PullRequest) testPatch() (err error) {
602 602
 // NewPullRequest creates new pull request with labels for repository.
603 603
 func NewPullRequest(repo *Repository, pull *Issue, labelIDs []int64, uuids []string, pr *PullRequest, patch []byte) (err error) {
604 604
 	sess := x.NewSession()
605
-	defer sessionRelease(sess)
605
+	defer sess.Close()
606 606
 	if err = sess.Begin(); err != nil {
607 607
 		return err
608 608
 	}

+ 6 - 6
models/repo.go

@@ -1271,7 +1271,7 @@ func CreateRepository(u *User, opts CreateRepoOptions) (_ *Repository, err error
1271 1271
 	}
1272 1272
 
1273 1273
 	sess := x.NewSession()
1274
-	defer sessionRelease(sess)
1274
+	defer sess.Close()
1275 1275
 	if err = sess.Begin(); err != nil {
1276 1276
 		return nil, err
1277 1277
 	}
@@ -1355,7 +1355,7 @@ func TransferOwnership(doer *User, newOwnerName string, repo *Repository) error
1355 1355
 	}
1356 1356
 
1357 1357
 	sess := x.NewSession()
1358
-	defer sessionRelease(sess)
1358
+	defer sess.Close()
1359 1359
 	if err = sess.Begin(); err != nil {
1360 1360
 		return fmt.Errorf("sess.Begin: %v", err)
1361 1361
 	}
@@ -1580,7 +1580,7 @@ func updateRepository(e Engine, repo *Repository, visibilityChanged bool) (err e
1580 1580
 // UpdateRepository updates a repository
1581 1581
 func UpdateRepository(repo *Repository, visibilityChanged bool) (err error) {
1582 1582
 	sess := x.NewSession()
1583
-	defer sessionRelease(sess)
1583
+	defer sess.Close()
1584 1584
 	if err = sess.Begin(); err != nil {
1585 1585
 		return err
1586 1586
 	}
@@ -1625,7 +1625,7 @@ func DeleteRepository(uid, repoID int64) error {
1625 1625
 	}
1626 1626
 
1627 1627
 	sess := x.NewSession()
1628
-	defer sessionRelease(sess)
1628
+	defer sess.Close()
1629 1629
 	if err = sess.Begin(); err != nil {
1630 1630
 		return err
1631 1631
 	}
@@ -2240,7 +2240,7 @@ func ForkRepository(u *User, oldRepo *Repository, name, desc string) (_ *Reposit
2240 2240
 	}
2241 2241
 
2242 2242
 	sess := x.NewSession()
2243
-	defer sessionRelease(sess)
2243
+	defer sess.Close()
2244 2244
 	if err = sess.Begin(); err != nil {
2245 2245
 		return nil, err
2246 2246
 	}
@@ -2284,7 +2284,7 @@ func ForkRepository(u *User, oldRepo *Repository, name, desc string) (_ *Reposit
2284 2284
 
2285 2285
 	// Copy LFS meta objects in new session
2286 2286
 	sess2 := x.NewSession()
2287
-	defer sessionRelease(sess2)
2287
+	defer sess2.Close()
2288 2288
 	if err = sess2.Begin(); err != nil {
2289 2289
 		return nil, err
2290 2290
 	}

+ 3 - 3
models/repo_collaboration.go

@@ -46,7 +46,7 @@ func (repo *Repository) AddCollaborator(u *User) error {
46 46
 	collaboration.Mode = AccessModeWrite
47 47
 
48 48
 	sess := x.NewSession()
49
-	defer sessionRelease(sess)
49
+	defer sess.Close()
50 50
 	if err = sess.Begin(); err != nil {
51 51
 		return err
52 52
 	}
@@ -136,7 +136,7 @@ func (repo *Repository) ChangeCollaborationAccessMode(uid int64, mode AccessMode
136 136
 	collaboration.Mode = mode
137 137
 
138 138
 	sess := x.NewSession()
139
-	defer sessionRelease(sess)
139
+	defer sess.Close()
140 140
 	if err = sess.Begin(); err != nil {
141 141
 		return err
142 142
 	}
@@ -161,7 +161,7 @@ func (repo *Repository) DeleteCollaboration(uid int64) (err error) {
161 161
 	}
162 162
 
163 163
 	sess := x.NewSession()
164
-	defer sessionRelease(sess)
164
+	defer sess.Close()
165 165
 	if err = sess.Begin(); err != nil {
166 166
 		return err
167 167
 	}

+ 1 - 1
models/repo_editor.go

@@ -401,7 +401,7 @@ func DeleteUploads(uploads ...*Upload) (err error) {
401 401
 	}
402 402
 
403 403
 	sess := x.NewSession()
404
-	defer sessionRelease(sess)
404
+	defer sess.Close()
405 405
 	if err = sess.Begin(); err != nil {
406 406
 		return err
407 407
 	}

+ 4 - 4
models/ssh_key.go

@@ -430,7 +430,7 @@ func AddPublicKey(ownerID int64, name, content string) (*PublicKey, error) {
430 430
 	}
431 431
 
432 432
 	sess := x.NewSession()
433
-	defer sessionRelease(sess)
433
+	defer sess.Close()
434 434
 	if err = sess.Begin(); err != nil {
435 435
 		return nil, err
436 436
 	}
@@ -535,7 +535,7 @@ func DeletePublicKey(doer *User, id int64) (err error) {
535 535
 	}
536 536
 
537 537
 	sess := x.NewSession()
538
-	defer sessionRelease(sess)
538
+	defer sess.Close()
539 539
 	if err = sess.Begin(); err != nil {
540 540
 		return err
541 541
 	}
@@ -732,7 +732,7 @@ func AddDeployKey(repoID int64, name, content string) (*DeployKey, error) {
732 732
 	}
733 733
 
734 734
 	sess := x.NewSession()
735
-	defer sessionRelease(sess)
735
+	defer sess.Close()
736 736
 	if err = sess.Begin(); err != nil {
737 737
 		return nil, err
738 738
 	}
@@ -812,7 +812,7 @@ func DeleteDeployKey(doer *User, id int64) error {
812 812
 	}
813 813
 
814 814
 	sess := x.NewSession()
815
-	defer sessionRelease(sess)
815
+	defer sess.Close()
816 816
 	if err = sess.Begin(); err != nil {
817 817
 		return err
818 818
 	}

+ 3 - 3
models/user.go

@@ -436,7 +436,7 @@ func (u *User) UploadAvatar(data []byte) error {
436 436
 	m := resize.Resize(avatar.AvatarSize, avatar.AvatarSize, img, resize.NearestNeighbor)
437 437
 
438 438
 	sess := x.NewSession()
439
-	defer sessionRelease(sess)
439
+	defer sess.Close()
440 440
 	if err = sess.Begin(); err != nil {
441 441
 		return err
442 442
 	}
@@ -715,7 +715,7 @@ func CreateUser(u *User) (err error) {
715 715
 	u.MaxRepoCreation = -1
716 716
 
717 717
 	sess := x.NewSession()
718
-	defer sessionRelease(sess)
718
+	defer sess.Close()
719 719
 	if err = sess.Begin(); err != nil {
720 720
 		return err
721 721
 	}
@@ -1033,7 +1033,7 @@ func deleteUser(e *xorm.Session, u *User) error {
1033 1033
 // but issues/comments/pulls will be kept and shown as someone has been deleted.
1034 1034
 func DeleteUser(u *User) (err error) {
1035 1035
 	sess := x.NewSession()
1036
-	defer sessionRelease(sess)
1036
+	defer sess.Close()
1037 1037
 	if err = sess.Begin(); err != nil {
1038 1038
 		return err
1039 1039
 	}

+ 2 - 2
models/user_follow.go

@@ -24,7 +24,7 @@ func FollowUser(userID, followID int64) (err error) {
24 24
 	}
25 25
 
26 26
 	sess := x.NewSession()
27
-	defer sessionRelease(sess)
27
+	defer sess.Close()
28 28
 	if err = sess.Begin(); err != nil {
29 29
 		return err
30 30
 	}
@@ -50,7 +50,7 @@ func UnfollowUser(userID, followID int64) (err error) {
50 50
 	}
51 51
 
52 52
 	sess := x.NewSession()
53
-	defer sessionRelease(sess)
53
+	defer sess.Close()
54 54
 	if err = sess.Begin(); err != nil {
55 55
 		return err
56 56
 	}

+ 2 - 2
models/user_mail.go

@@ -127,7 +127,7 @@ func (email *EmailAddress) Activate() error {
127 127
 	}
128 128
 
129 129
 	sess := x.NewSession()
130
-	defer sessionRelease(sess)
130
+	defer sess.Close()
131 131
 	if err = sess.Begin(); err != nil {
132 132
 		return err
133 133
 	}
@@ -208,7 +208,7 @@ func MakeEmailPrimary(email *EmailAddress) error {
208 208
 	}
209 209
 
210 210
 	sess := x.NewSession()
211
-	defer sessionRelease(sess)
211
+	defer sess.Close()
212 212
 	if err = sess.Begin(); err != nil {
213 213
 		return err
214 214
 	}

+ 1 - 1
models/webhook.go

@@ -267,7 +267,7 @@ func UpdateWebhook(w *Webhook) error {
267 267
 // ID must be specified and do not assign unnecessary fields.
268 268
 func deleteWebhook(bean *Webhook) (err error) {
269 269
 	sess := x.NewSession()
270
-	defer sessionRelease(sess)
270
+	defer sess.Close()
271 271
 	if err = sess.Begin(); err != nil {
272 272
 		return err
273 273
 	}