-
Type:
Improvement
-
Resolution: Unresolved
-
Priority:
Unknown
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
Context
Currently the Go Driver GridFSBucket.OpenUploadStream method is not goroutine-safe. While we don't explicitly document that the GridFS API is goroutine safe, it's surprising to users because the Go Driver CRUD API is goroutine-safe and there's no technical reason that the GridFS API shouldn't be goroutine-safe.
We should make GridFSBucket.OpenUploadStream goroutine-safe.
Definition of done
OpenUploadStream
- Add a test that calls GridFSBucket.OpenUploadStream in different goroutines and asserts that the uploaded results are correct.
- Also test GridFSBucket.OpenUploadStreamWithID with a similar test.
- See a proof-of-concept test generated by Claude here.
- Fix any concurrency bugs detected using the -race test flag.
- Update the documentation for GridFSBucket.OpenUploadStream and GridFSBucket.OpenUploadStreamWithID to indicate they're safe to call from different goroutines. For example:
// It is safe for concurrent use by multiple goroutines.
UploadFromStream
- Add a test that calls GridFSBucket.UploadFromStream in different goroutines and asserts that the uploaded results are correct.
- Also test GridFSBucket.UploadFromStreamWithID with a similar test.
- See a proof-of-concept test generated by Claude here.
- Fix any concurrency bugs detected using the -race test flag.
- Update the documentation for GridFSBucket.UploadFromStream to indicate it's safe to call from different goroutines. For example:
// It is safe for concurrent use by multiple goroutines.
Pitfalls
What should the implementer watch out for? What are the risks?
- is duplicated by
-
GODRIVER-4124 Make GridFSBucket.UploadFromStream goroutine-safe
-
- Closed
-