Database: Is it necessary to use Copy() function? #6
Labels
No Label
bug
change
check
Comp::Backend
Comp::Database
Comp::ICCC
Comp::Logging
Comp::Sessions
Comp::System
Comp::Users
enhancement
note
outdated
question
Ready2Test
security
todo
wontfix
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: Go/Ocean#6
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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 :)