You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When mongo manually opens a transaction, the second parameter of mongo.NewSessionContext needs to pass its own session inside the mongo sdk, but this session cannot be obtained within the framework. I currently obtain it through reflection. The following is my temporary solution.
When performing specific db insert, update and other operations, it will be judged whether the session injected into ctx when mongo.NewSessionContext is its own session within the SDK. If not, it will not be treated as an open transaction.
When mongo manually opens a transaction, the second parameter of mongo.NewSessionContext needs to pass its own session inside the mongo sdk, but this session cannot be obtained within the framework. I currently obtain it through reflection. The following is my temporary solution.
When performing specific db insert, update and other operations, it will be judged whether the session injected into ctx when mongo.NewSessionContext is its own session within the SDK. If not, it will not be treated as an open transaction.
mongo sdk logic:
https://github.com/mongodb/mongo-go-driver/blob/v1/mongo/collection.go#L268
https://github.com/mongodb/mongo-go-driver/blob/v1/mongo/session.go#L383
The text was updated successfully, but these errors were encountered: