novatrixtech / mercurius

Mercurius gives you speed when create 'Go' applications. It lets you being focused at business.
Apache License 2.0
144 stars 27 forks source link

fixed mongodb session not closing bug - Issue #48 #49

Closed PhillBeck closed 6 years ago

PhillBeck commented 6 years ago

Apparently, on line 31, when you did mgoSession, erro := mgo.Dial(mongoDbURI), go was creating a new local-scoped mgoSession, instead of using the package-scoped one.

The package-scoped mgoSession was always nil, and the code never entered the if block on line 25. The result was that in every call to GetMongoSession(), a new session was opened, then Copy()ed, creating 2 sessions. The copy session was closed by the caller code, but the other one remained open.

Replacing := by = on seemed to fix the issue, but then a new var erro error nedded to be added.

felipeweb commented 6 years ago

@PhillBeck thank you!!!