Is it necessary to create for any database call a copied database session or is it fine to use the global session?
At the Gophercon, Gustavo Niemeyer said this:
Manipulating MongoDB using mgo
Gustavo described how to use mgo.Dial to connect to MongoDB. Once connected, the caller receives a session. Concurrent callers typically use copied sessions (obtained using the Copy() method).
[...]
Concurrency using separate (Copy’d) sessions
If you use a global session with the mgo driver, each query will wait for the previous query to return. The mgo driver lets you perform concurrent operations against the database by using separate, copied sessions. When you use a separate session, the query is issued without waiting.
Is it necessary to create for any database call a copied database session or is it fine to use the global session?
<b>At the Gophercon, Gustavo Niemeyer said this:</b>
<b>Manipulating MongoDB using mgo</b>
Gustavo described how to use mgo.Dial to connect to MongoDB. Once connected, the caller receives a session. Concurrent callers typically use copied sessions (obtained using the Copy() method).
[...]
<b>Concurrency using separate (Copy’d) sessions</b>
If you use a global session with the mgo driver, each query will wait for the previous query to return. The mgo driver lets you perform concurrent operations against the database by using separate, copied sessions. When you use a separate session, the query is issued without waiting.
Done. The DB() and GridFS() functions are returning now also the copied session. All Ocean's internal packages are using this new implementation and they are also closing the sessions!
Done. The DB() and GridFS() functions are returning now also the copied session. All Ocean's internal packages are using this new implementation and they are also closing the sessions!
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Is it necessary to create for any database call a copied database session or is it fine to use the global session?
At the Gophercon, Gustavo Niemeyer said this:
Manipulating MongoDB using mgo
Gustavo described how to use mgo.Dial to connect to MongoDB. Once connected, the caller receives a session. Concurrent callers typically use copied sessions (obtained using the Copy() method).
[...]
Concurrency using separate (Copy’d) sessions
If you use a global session with the mgo driver, each query will wait for the previous query to return. The mgo driver lets you perform concurrent operations against the database by using separate, copied sessions. When you use a separate session, the query is issued without waiting.
Source: http://gophercon.sourcegraph.com/post/83822679358/gustavo-niemeyer-and-steve-francia-painless-data
Yes, this is a bug!
http://www.youtube.com/watch?v=9OkclcLgR0U
It is necessary to call Close() for the copied session!
Done. The DB() and GridFS() functions are returning now also the copied session. All Ocean's internal packages are using this new implementation and they are also closing the sessions!
Tests passed :)