[GODRIVER-704] Document that mongo.SessionContext is not goroutine safe Created: 14/Dec/18 Updated: 28/Oct/23 Resolved: 30/Jan/19 |
|
| Status: | Closed |
| Project: | Go Driver |
| Component/s: | Documentation |
| Affects Version/s: | 0.1.0 |
| Fix Version/s: | 0.3.0 |
| Type: | Improvement | Priority: | Minor - P4 |
| Reporter: | xwp50419 | Assignee: | Isabella Siu (Inactive) |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
mongo:latest |
||
| Issue Links: |
|
||||||||
| Description |
|
Since mongo.SessionContext is not goroutine safe and it should be documented as such.
The ErrorExample will randomly generate the following errors, even if I specified the TransactionOptions<options.Transaction().SetWriteConcern(writeconcern.New(writeconcern.WMajority())).SetReadConcern(readconcern.Majority()).SetReadPreference(readpref.Primary())> in sess.StartTransaction() |
| Comments |
| Comment by Githook User [ 30/Jan/19 ] |
|
Author: {'username': 'iwysiu', 'email': 'isabella.siu@10gen.com', 'name': 'Isabella Siu'}Message: Change-Id: I167bda20f16716287331e29faff8fe9a11b3a84c |
| Comment by Ian Whalen (Inactive) [ 07/Jan/19 ] |
|
Need to document that you shouldn't be using SessionContext in multiple goroutines. |
| Comment by Kristofer Brandow (Inactive) [ 19/Dec/18 ] |
|
Hi xwp50419, By goroutine safe I mean that the SessionContext is not safe for concurrent use without coordination, because a Session is not safe for concurrent use. Using the SessionContext in multiple goroutines concurrently without coordination is not supported. --Kris |
| Comment by xwp50419 [ 19/Dec/18 ] |
|
Hi Kris, |
| Comment by Kristofer Brandow (Inactive) [ 17/Dec/18 ] |
|
Hi xwp50419, The SessionContext type is not goroutine safe, so it cannot be used concurrently. You cannot pass the SessionContext to goroutines and it shouldn't escape the scope of the function passed to mongo.WithSession. --Kris |