What version of MongoDB are you using (mongod --version)?
4
What version of Go are you using (go version)?
1.12
What operating system and processor architecture are you using (go env)?
ubuntu, linux, amd
What did you do?
Trying to copy the session and have different socket timeout value. Sadly, if I set SetSocketTimeout on one session, value is changed on all sessions that were copied using copySessionhttps://github.com/globalsign/mgo/blob/master/session.go#L844
This is because method creates new object of Session but reuses pointer values in object properties, e.g.:
Session struct has property dialInfo *DialInfo.
The new Session object takes pointer value from Session that should be copied :
What version of MongoDB are you using (
mongod --version
)?What version of Go are you using (
go version
)?What operating system and processor architecture are you using (
go env
)?What did you do?
Trying to copy the session and have different socket timeout value. Sadly, if I set
SetSocketTimeout
on one session, value is changed on all sessions that were copied usingcopySession
https://github.com/globalsign/mgo/blob/master/session.go#L844This is because method creates new object of
Session
but reuses pointer values in object properties, e.g.:Session
struct has propertydialInfo *DialInfo
. The new Session object takes pointer value from Session that should be copied :SetSocketTimeout
method sets values and changes are applied to all the sessions that were copied.Can you reproduce the issue on the latest
development
branch?Probably, yes. Didn't see any related issues or PRs.